Blueprint containing bootsteps that can be applied to objects.
Attributes
| Attribute | Type | Description |
|---|
| GraphFormatter | [StepFormatter](stepformatter.md?sid=celery_bootsteps_stepformatter) = StepFormatter | The formatter class used to visualize the dependency graph of bootsteps. |
| name | string = null | Set explicit name for this blueprint. |
| state | integer = null | The current operational state of the blueprint, used to track progress through the lifecycle. |
| started | integer = 0 | The count of bootsteps that have been successfully started during the blueprint's execution. |
| default_steps | set = set() | A set of bootstep classes that are included in the blueprint by default. |
| state_to_name | dict = {0: 'initializing', RUN: 'running', CLOSE: 'closing', TERMINATE: 'terminating'} | A mapping of numeric state constants to their corresponding human-readable string labels. |
Constructor
Signature
def Blueprint(
steps: Sequence[Union[str, [Step](step.md?sid=celery_bootsteps_step)]] = None,
name: str = None,
on_start: Callable = None,
on_close: Callable = None,
on_stopped: Callable = None
) - > null
Parameters
| Name | Type | Description |
|---|
| steps | Sequence[Union[str, [Step](step.md?sid=celery_bootsteps_step)]] = None | A list of steps to be included in the blueprint. |
| name | str = None | An explicit name for the blueprint; defaults to the class name if not provided. |
| on_start | Callable = None | Optional callback executed after the blueprint starts. |
| on_close | Callable = None | Optional callback executed before the blueprint closes. |
| on_stopped | Callable = None | Optional callback executed after the blueprint has stopped. |
Methods
start()
@classmethod
def start(
parent: object
) - > null
Starts the blueprint and all its associated bootsteps in the order they were defined. This method triggers the on_start callback and sequentially calls the start method on each step.
Parameters
| Name | Type | Description |
|---|
| parent | object | The parent object that owns the steps being started |
Returns
human_state()
@classmethod
def human_state() - > string
Returns a human-readable string representation of the current blueprint state, such as 'running' or 'closing'.
Returns
| Type | Description |
|---|
string | The name of the current state mapped from the internal state integer |
info()
@classmethod
def info(
parent: object
) - > dict
Gathers diagnostic or status information from all steps within the blueprint.
Parameters
| Name | Type | Description |
|---|
| parent | object | The parent object used to retrieve step information |
Returns
| Type | Description |
|---|
dict | A dictionary containing merged information from all active bootsteps |
close()
@classmethod
def close(
parent: object
) - > null
Initiates the shutdown sequence by triggering the on_close callback and closing all steps in forward order.
Parameters
| Name | Type | Description |
|---|
| parent | object | The parent object whose steps are being closed |
Returns
restart()
@classmethod
def restart(
parent: object,
method: string = stop,
description: string = restarting,
propagate: boolean = False
) - > null
Restarts the blueprint by sending a specific control method to all steps.
Parameters
| Name | Type | Description |
|---|
| parent | object | The parent object containing the steps to restart |
| method | string = stop | The name of the method to call on each step during restart |
| description | string = restarting | A label used for logging the restart progress |
| propagate | boolean = False | Whether to allow exceptions raised by steps to propagate upwards |
Returns
send_all()
@classmethod
def send_all(
parent: object,
method: string,
description: string = null,
reverse: boolean = True,
propagate: boolean = True,
args: tuple = ()
) - > null
Iterates through all steps and executes a specified method on each, optionally in reverse order.
Parameters
| Name | Type | Description |
|---|
| parent | object | The parent object containing the steps |
| method | string | The name of the method to invoke on each step |
| description | string = null | Optional log message prefix; defaults to the method name |
| reverse | boolean = True | If true, iterates through steps in reverse order |
| propagate | boolean = True | If true, exceptions in step methods will stop execution and be raised |
| args | tuple = () | Positional arguments to pass to the step method |
Returns
stop()
@classmethod
def stop(
parent: object,
close: boolean = True,
terminate: boolean = False
) - > null
Stops or terminates the blueprint, ensuring all steps are closed and the on_stopped callback is executed.
Parameters
| Name | Type | Description |
|---|
| parent | object | The parent object whose steps are being stopped |
| close | boolean = True | Whether to call the close method before stopping |
| terminate | boolean = False | If true, uses termination logic instead of a graceful stop |
Returns
join()
@classmethod
def join(
timeout: float = null
) - > null
Blocks until the blueprint shutdown process is complete, optionally with a timeout.
Parameters
| Name | Type | Description |
|---|
| timeout | float = null | The maximum time in seconds to wait for shutdown |
Returns
apply()
@classmethod
def apply(
parent: object
) - > [Blueprint](blueprint.md?sid=celery_bootsteps_blueprint)
Apply the steps in this blueprint to an object. This will apply the init and include methods of each step, with the object as argument.
Parameters
| Name | Type | Description |
|---|
| parent | object | The object to which the bootsteps will be applied |
Returns
| Type | Description |
|---|
[Blueprint](blueprint.md?sid=celery_bootsteps_blueprint) | The blueprint instance itself after steps have been applied |
connect_with()
@classmethod
def connect_with(
other: [Blueprint](blueprint.md?sid=celery_bootsteps_blueprint)
) - > null
Links this blueprint's dependency graph with another, creating an edge between their respective steps.
Parameters
| Name | Type | Description |
|---|
| other | [Blueprint](blueprint.md?sid=celery_bootsteps_blueprint) | The other blueprint to connect to this one |
Returns
claim_steps()
@classmethod
def claim_steps() - > dict
Resolves and loads all step types defined in the blueprint into a dictionary.
Returns
| Type | Description |
|---|
dict | A mapping of step names to their resolved step classes |
load_step()
@classmethod
def load_step(
step: string
) - > tuple
Resolves a step string or symbol into a concrete step class and its name.
Parameters
| Name | Type | Description |
|---|
| step | string | The string path or symbol representing the step to load |
Returns
| Type | Description |
|---|
tuple | A tuple containing the step name and the resolved step class |
alias()
@classmethod
def alias() - > string
Property that returns a formatted label for the blueprint used in logging and debugging.
Returns
| Type | Description |
|---|
string | The display label for this blueprint instance |