Skip to main content

Blueprint

Blueprint containing bootsteps that can be applied to objects.

Attributes

AttributeTypeDescription
GraphFormatter[StepFormatter](stepformatter.md?sid=celery_bootsteps_stepformatter) = StepFormatterThe formatter class used to visualize the dependency graph of bootsteps.
namestring = nullSet explicit name for this blueprint.
stateinteger = nullThe current operational state of the blueprint, used to track progress through the lifecycle.
startedinteger = 0The count of bootsteps that have been successfully started during the blueprint's execution.
default_stepsset = set()A set of bootstep classes that are included in the blueprint by default.
state_to_namedict = {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

NameTypeDescription
stepsSequence[Union[str, [Step](step.md?sid=celery_bootsteps_step)]] = NoneA list of steps to be included in the blueprint.
namestr = NoneAn explicit name for the blueprint; defaults to the class name if not provided.
on_startCallable = NoneOptional callback executed after the blueprint starts.
on_closeCallable = NoneOptional callback executed before the blueprint closes.
on_stoppedCallable = NoneOptional 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

NameTypeDescription
parentobjectThe parent object that owns the steps being started

Returns

TypeDescription
null

human_state()

@classmethod
def human_state() - > string

Returns a human-readable string representation of the current blueprint state, such as 'running' or 'closing'.

Returns

TypeDescription
stringThe 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

NameTypeDescription
parentobjectThe parent object used to retrieve step information

Returns

TypeDescription
dictA 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

NameTypeDescription
parentobjectThe parent object whose steps are being closed

Returns

TypeDescription
null

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

NameTypeDescription
parentobjectThe parent object containing the steps to restart
methodstring = stopThe name of the method to call on each step during restart
descriptionstring = restartingA label used for logging the restart progress
propagateboolean = FalseWhether to allow exceptions raised by steps to propagate upwards

Returns

TypeDescription
null

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

NameTypeDescription
parentobjectThe parent object containing the steps
methodstringThe name of the method to invoke on each step
descriptionstring = nullOptional log message prefix; defaults to the method name
reverseboolean = TrueIf true, iterates through steps in reverse order
propagateboolean = TrueIf true, exceptions in step methods will stop execution and be raised
argstuple = ()Positional arguments to pass to the step method

Returns

TypeDescription
null

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

NameTypeDescription
parentobjectThe parent object whose steps are being stopped
closeboolean = TrueWhether to call the close method before stopping
terminateboolean = FalseIf true, uses termination logic instead of a graceful stop

Returns

TypeDescription
null

join()

@classmethod
def join(
timeout: float = null
) - > null

Blocks until the blueprint shutdown process is complete, optionally with a timeout.

Parameters

NameTypeDescription
timeoutfloat = nullThe maximum time in seconds to wait for shutdown

Returns

TypeDescription
null

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

NameTypeDescription
parentobjectThe object to which the bootsteps will be applied

Returns

TypeDescription
[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

NameTypeDescription
other[Blueprint](blueprint.md?sid=celery_bootsteps_blueprint)The other blueprint to connect to this one

Returns

TypeDescription
null

claim_steps()

@classmethod
def claim_steps() - > dict

Resolves and loads all step types defined in the blueprint into a dictionary.

Returns

TypeDescription
dictA 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

NameTypeDescription
stepstringThe string path or symbol representing the step to load

Returns

TypeDescription
tupleA 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

TypeDescription
stringThe display label for this blueprint instance