Skip to main content

MultiTool

The celery multi program.

Attributes​

AttributeTypeDescription
MultiParserclass = MultiParserThe parser class used to process and expand node-specific arguments from the command line.
OptionParserclass = NamespacedOptionParserThe parser class used to handle namespaced command-line options for the multi-node manager.
reserved_optionslist = [('--nosplash', 'nosplash'), ('--quiet', 'quiet'), ('-q', 'quiet'), ('--verbose', 'verbose'), ('--no-color', 'no_color')]A list of tuples mapping command-line flags to internal attribute names for global configuration like logging and color.
stop_verifycallable = stopwaitA compatibility alias for the stopwait method used to shut down nodes and verify their termination.

Constructor​

Signature​

def MultiTool(
env: Any = None,
cmd: Any = None,
fh: Any = None,
stdout: Any = None,
stderr: Any = None,
**kwargs: dict
) - > null

Parameters​

NameTypeDescription
envAny = NoneThe environment configuration for the tool.
cmdAny = NoneThe command to be executed.
fhAny = NoneAn old alias for stdout used for terminal output.
stdoutAny = NoneThe standard output stream.
stderrAny = NoneThe standard error stream.
**kwargsdictAdditional keyword arguments for terminal setup.

Methods​


execute_from_commandline()​

@classmethod
def execute_from_commandline(
argv: list,
cmd: string = null
) - > int

Parses command-line arguments and executes the corresponding multi-node command.

Parameters​

NameTypeDescription
argvlistThe list of command-line arguments including the program name.
cmdstring = nullThe base command to execute for each node.

Returns​

TypeDescription
intThe exit code of the executed command, typically 0 for success.

validate_arguments()​

@classmethod
def validate_arguments(
argv: list
) - > boolean

Validates that the provided arguments contain a valid command name.

Parameters​

NameTypeDescription
argvlistThe list of arguments to validate.

Returns​

TypeDescription
booleanTrue if the first argument is present and does not start with a hyphen.

call_command()​

@classmethod
def call_command(
command: string,
argv: list
) - > int

Dispatches the execution to the internal method mapped to the specified command name.

Parameters​

NameTypeDescription
commandstringThe name of the command to invoke (e.g., 'start', 'stop').
argvlistThe arguments to pass to the command handler.

Returns​

TypeDescription
intThe result of the command execution or an error code if the command is invalid.

start()​

@classmethod
def start(
cluster: [Cluster](../../apps/multi/cluster.md?sid=celery_apps_multi_cluster)
) - > int

Starts the defined cluster of nodes.

Parameters​

NameTypeDescription
cluster[Cluster](../../apps/multi/cluster.md?sid=celery_apps_multi_cluster)The cluster instance containing the nodes to be started.

Returns​

TypeDescription
intReturns 1 if any node failed to start, otherwise 0.

stop()​

@classmethod
def stop(
cluster: [Cluster](../../apps/multi/cluster.md?sid=celery_apps_multi_cluster),
sig: int
) - > any

Sends a stop signal to the nodes in the cluster.

Parameters​

NameTypeDescription
cluster[Cluster](../../apps/multi/cluster.md?sid=celery_apps_multi_cluster)The cluster instance to stop.
sigintThe signal number to send to the nodes.

Returns​

TypeDescription
anyThe return value from the cluster's stop operation.

stopwait()​

@classmethod
def stopwait(
cluster: [Cluster](../../apps/multi/cluster.md?sid=celery_apps_multi_cluster),
sig: int
) - > any

Sends a stop signal to the nodes and waits for them to terminate.

Parameters​

NameTypeDescription
cluster[Cluster](../../apps/multi/cluster.md?sid=celery_apps_multi_cluster)The cluster instance to stop.
sigintThe signal number to send to the nodes.

Returns​

TypeDescription
anyThe return value from the cluster's stopwait operation.

restart()​

@classmethod
def restart(
cluster: [Cluster](../../apps/multi/cluster.md?sid=celery_apps_multi_cluster),
sig: int
) - > int

Restarts the nodes in the cluster by stopping and then starting them.

Parameters​

NameTypeDescription
cluster[Cluster](../../apps/multi/cluster.md?sid=celery_apps_multi_cluster)The cluster instance to restart.
sigintThe signal number used for the stop phase of the restart.

Returns​

TypeDescription
intReturns 1 if any node failed to restart, otherwise 0.

names()​

@classmethod
def names(
cluster: [Cluster](../../apps/multi/cluster.md?sid=celery_apps_multi_cluster)
) - > null

Prints the names of all nodes defined in the cluster to the terminal.

Parameters​

NameTypeDescription
cluster[Cluster](../../apps/multi/cluster.md?sid=celery_apps_multi_cluster)The cluster whose node names should be displayed.

Returns​

TypeDescription
nullnull

get()​

@classmethod
def get(
wanted: string,
argv: list
) - > int

Retrieves and displays the full command-line arguments for a specific node.

Parameters​

NameTypeDescription
wantedstringThe name of the specific node to retrieve.
argvlistArguments used to construct the cluster context.

Returns​

TypeDescription
intReturns EX_OK on success or EX_FAILURE if the node is not found.

show()​

@classmethod
def show(
cluster: [Cluster](../../apps/multi/cluster.md?sid=celery_apps_multi_cluster)
) - > int

Displays the full command-line strings that would be executed for every node in the cluster.

Parameters​

NameTypeDescription
cluster[Cluster](../../apps/multi/cluster.md?sid=celery_apps_multi_cluster)The cluster instance to inspect.

Returns​

TypeDescription
intThe exit status of the operation.

kill()​

@classmethod
def kill(
cluster: [Cluster](../../apps/multi/cluster.md?sid=celery_apps_multi_cluster)
) - > any

Forcefully terminates the nodes in the cluster.

Parameters​

NameTypeDescription
cluster[Cluster](../../apps/multi/cluster.md?sid=celery_apps_multi_cluster)The cluster instance to kill.

Returns​

TypeDescription
anyThe result of the cluster kill operation.

expand()​

@classmethod
def expand(
template: string,
argv: list
) - > int

Expands a template string using the variables available for each node in the cluster.

Parameters​

NameTypeDescription
templatestringThe string template containing placeholders to expand.
argvlistArguments used to construct the cluster context.

Returns​

TypeDescription
intThe exit status of the operation.

help()​

@classmethod
def help(
argv: list
) - > null

Displays the program's documentation and usage information.

Parameters​

NameTypeDescription
argvlistOptional arguments for the help command.

Returns​

TypeDescription
nullnull

cluster_from_argv()​

@classmethod
def cluster_from_argv(
argv: list,
cmd: string = null
) - > [Cluster](../../apps/multi/cluster.md?sid=celery_apps_multi_cluster)

Creates a Cluster object from the provided command-line arguments.

Parameters​

NameTypeDescription
argvlistThe arguments defining the cluster nodes.
cmdstring = nullThe base command for the nodes.

Returns​

TypeDescription
[Cluster](../../apps/multi/cluster.md?sid=celery_apps_multi_cluster)An initialized Cluster instance.

Cluster()​

@classmethod
def Cluster(
nodes: list,
cmd: string = null
) - > [Cluster](../../apps/multi/cluster.md?sid=celery_apps_multi_cluster)

Factory method to instantiate a Cluster with the appropriate event callbacks.

Parameters​

NameTypeDescription
nodeslistThe list of node definitions.
cmdstring = nullThe base command for the nodes.

Returns​

TypeDescription
[Cluster](../../apps/multi/cluster.md?sid=celery_apps_multi_cluster)A Cluster instance configured with the tool's logging and event handlers.

on_stopping_preamble()​

@classmethod
def on_stopping_preamble(
nodes: list
) - > null

Logs a message indicating that the node shutdown process has started.

Parameters​

NameTypeDescription
nodeslistThe list of nodes being stopped.

Returns​

TypeDescription
nullnull

on_send_signal()​

@classmethod
def on_send_signal(
node: [Node](../../apps/multi/node.md?sid=celery_apps_multi_node),
sig: int
) - > null

Logs the action of sending a specific signal to a node.

Parameters​

NameTypeDescription
node[Node](../../apps/multi/node.md?sid=celery_apps_multi_node)The node receiving the signal.
sigintThe signal number being sent.

Returns​

TypeDescription
nullnull

on_still_waiting_for()​

@classmethod
def on_still_waiting_for(
nodes: list
) - > null

Logs a status message listing nodes that have not yet shut down.

Parameters​

NameTypeDescription
nodeslistThe list of nodes still active.

Returns​

TypeDescription
nullnull

on_still_waiting_progress()​

@classmethod
def on_still_waiting_progress(
nodes: list
) - > null

Logs a progress indicator (dot) while waiting for nodes to exit.

Parameters​

NameTypeDescription
nodeslistThe list of nodes still being waited upon.

Returns​

TypeDescription
nullnull

on_still_waiting_end()​

@classmethod
def on_still_waiting_end() - > null

Finalizes the progress logging line for waiting operations.

Returns​

TypeDescription
nullnull

on_node_signal_dead()​

@classmethod
def on_node_signal_dead(
node: [Node](../../apps/multi/node.md?sid=celery_apps_multi_node)
) - > null

Logs an error when a signal cannot be sent because the node process does not exist.

Parameters​

NameTypeDescription
node[Node](../../apps/multi/node.md?sid=celery_apps_multi_node)The node that could not be signaled.

Returns​

TypeDescription
nullnull

on_node_start()​

@classmethod
def on_node_start(
node: [Node](../../apps/multi/node.md?sid=celery_apps_multi_node)
) - > null

Logs the initiation of a node startup.

Parameters​

NameTypeDescription
node[Node](../../apps/multi/node.md?sid=celery_apps_multi_node)The node being started.

Returns​

TypeDescription
nullnull

on_node_restart()​

@classmethod
def on_node_restart(
node: [Node](../../apps/multi/node.md?sid=celery_apps_multi_node)
) - > null

Logs the initiation of a node restart.

Parameters​

NameTypeDescription
node[Node](../../apps/multi/node.md?sid=celery_apps_multi_node)The node being restarted.

Returns​

TypeDescription
nullnull

on_node_down()​

@classmethod
def on_node_down(
node: [Node](../../apps/multi/node.md?sid=celery_apps_multi_node)
) - > null

Logs that a node is down or has stopped.

Parameters​

NameTypeDescription
node[Node](../../apps/multi/node.md?sid=celery_apps_multi_node)The node that is down.

Returns​

TypeDescription
nullnull

on_node_shutdown_ok()​

@classmethod
def on_node_shutdown_ok(
node: [Node](../../apps/multi/node.md?sid=celery_apps_multi_node)
) - > null

Logs a successful shutdown confirmation for a specific node.

Parameters​

NameTypeDescription
node[Node](../../apps/multi/node.md?sid=celery_apps_multi_node)The node that shut down successfully.

Returns​

TypeDescription
nullnull

on_node_status()​

@classmethod
def on_node_status(
node: [Node](../../apps/multi/node.md?sid=celery_apps_multi_node),
retval: int
) - > null

Logs the success or failure status of a node operation based on its return value.

Parameters​

NameTypeDescription
node[Node](../../apps/multi/node.md?sid=celery_apps_multi_node)The node whose status is being reported.
retvalintThe exit code or return value of the node operation.

Returns​

TypeDescription
nullnull

on_node_signal()​

@classmethod
def on_node_signal(
node: [Node](../../apps/multi/node.md?sid=celery_apps_multi_node),
sig: int
) - > null

Logs a message indicating a signal is being sent to a specific node.

Parameters​

NameTypeDescription
node[Node](../../apps/multi/node.md?sid=celery_apps_multi_node)The target node.
sigintThe signal being sent.

Returns​

TypeDescription
nullnull

on_child_spawn()​

@classmethod
def on_child_spawn(
node: [Node](../../apps/multi/node.md?sid=celery_apps_multi_node),
argstr: string,
env: dict
) - > null

Logs the command-line string and environment used to spawn a child process.

Parameters​

NameTypeDescription
node[Node](../../apps/multi/node.md?sid=celery_apps_multi_node)The node being spawned.
argstrstringThe full command-line string executed.
envdictThe environment variables passed to the child process.

Returns​

TypeDescription
nullnull

on_child_signalled()​

@classmethod
def on_child_signalled(
node: [Node](../../apps/multi/node.md?sid=celery_apps_multi_node),
signum: int
) - > null

Logs that a child process was terminated by a system signal.

Parameters​

NameTypeDescription
node[Node](../../apps/multi/node.md?sid=celery_apps_multi_node)The node that was terminated.
signumintThe signal number that caused termination.

Returns​

TypeDescription
nullnull

on_child_failure()​

@classmethod
def on_child_failure(
node: [Node](../../apps/multi/node.md?sid=celery_apps_multi_node),
retcode: int
) - > null

Logs that a child process failed and reports its exit code.

Parameters​

NameTypeDescription
node[Node](../../apps/multi/node.md?sid=celery_apps_multi_node)The node that failed.
retcodeintThe non-zero exit code returned by the process.

Returns​

TypeDescription
nullnull

OK()​

@classmethod
def OK() - > string

Returns a colorized 'OK' string for status logging.

Returns​

TypeDescription
stringThe formatted 'OK' status string.

FAILED()​

@classmethod
def FAILED() - > string

Returns a colorized 'FAILED' string for status logging.

Returns​

TypeDescription
stringThe formatted 'FAILED' status string.

DOWN()​

@classmethod
def DOWN() - > string

Returns a colorized 'DOWN' string for status logging.

Returns​

TypeDescription
stringThe formatted 'DOWN' status string.