Skip to main content

Inspect

API for inspecting workers.

This class provides proxy for accessing Inspect API of workers. The API is defined in :py:mod:celery.worker.control

Attributes

AttributeTypeDescription
appCelery app = nullThe Celery application instance used to dispatch control commands to workers.
registered_tasksmethodAlias for the registered method, used to retrieve all tasks currently registered with the workers.

Constructor

Signature

def Inspect(
destination: list|str = null,
timeout: float = 1.0,
callback: callable = null,
connection: kombu.Connection = null,
app: [Celery](../base/celery.md?sid=celery_app_base_celery) = null,
limit: int = null,
pattern: str = null,
matcher: str = null
)

Parameters

NameTypeDescription
destination`liststr` = null
timeoutfloat = 1.0Timeout in seconds for waiting for replies.
callbackcallable = nullCallback to be called for each reply received.
connectionkombu.Connection = nullCustom connection to use for the broadcast.
app[Celery](../base/celery.md?sid=celery_app_base_celery) = nullThe Celery app instance to use.
limitint = nullLimit the number of replies to wait for.
patternstr = nullA pattern to match node names against.
matcherstr = nullThe matching algorithm to use (e.g., glob or re).

Methods


report()

@classmethod
def report() - > object

Return human readable report for each worker.

Returns

TypeDescription
objectDictionary {HOSTNAME: {'ok': REPORT_STRING}}.

clock()

@classmethod
def clock() - > object

Get the Clock value on workers.

Returns

TypeDescription
objectDictionary {HOSTNAME: CLOCK_VALUE}.

active()

@classmethod
def active(
safe: boolean = null
) - > object

Return list of tasks currently executed by workers.

Parameters

NameTypeDescription
safeboolean = nullSet to True to disable deserialization.

Returns

TypeDescription
objectDictionary {HOSTNAME: [TASK_INFO,...]}.

scheduled()

@classmethod
def scheduled(
safe: boolean = null
) - > object

Return list of scheduled tasks with details.

Parameters

NameTypeDescription
safeboolean = nullFlag to control safe deserialization of task data.

Returns

TypeDescription
objectDictionary {HOSTNAME: [TASK_SCHEDULED_INFO,...]}.

reserved()

@classmethod
def reserved(
safe: boolean = null
) - > object

Return list of currently reserved tasks, not including scheduled/active.

Parameters

NameTypeDescription
safeboolean = nullFlag to control safe deserialization of task data.

Returns

TypeDescription
objectDictionary {HOSTNAME: [TASK_INFO,...]}.

stats()

@classmethod
def stats() - > object

Return statistics of worker.

Returns

TypeDescription
objectDictionary {HOSTNAME: STAT_INFO} containing broker, uptime, and resource usage data.

revoked()

@classmethod
def revoked() - > object

Return list of revoked tasks.

Returns

TypeDescription
objectDictionary {HOSTNAME: [TASK_ID, ...]}.

registered()

@classmethod
def registered(
*taskinfoitems: string
) - > object

Return all registered tasks per worker.

Parameters

NameTypeDescription
*taskinfoitemsstringList of Task attributes to include in the response for each task.

Returns

TypeDescription
objectDictionary {HOSTNAME: [TASK1_INFO, ...]}.

ping()

@classmethod
def ping(
destination: array = null
) - > object

Ping all (or specific) workers.

Parameters

NameTypeDescription
destinationarray = nullIf set, a list of the hosts to send the command to, when empty broadcast to all workers.

Returns

TypeDescription
objectDictionary {HOSTNAME: {'ok': 'pong'}}.

active_queues()

@classmethod
def active_queues() - > object

Return information about queues from which worker consumes tasks.

Returns

TypeDescription
objectDictionary {HOSTNAME: [QUEUE_INFO, QUEUE_INFO,...]}.

query_task()

@classmethod
def query_task(
*ids: string
) - > object

Return detail of tasks currently executed by workers.

Parameters

NameTypeDescription
*idsstringIDs of tasks to be queried.

Returns

TypeDescription
objectDictionary {HOSTNAME: {TASK_ID: [STATE, TASK_INFO]}}.

conf()

@classmethod
def conf(
with_defaults: boolean = false
) - > object

Return configuration of each worker.

Parameters

NameTypeDescription
with_defaultsboolean = falseif set to True, method returns also configuration options with default values.

Returns

TypeDescription
objectDictionary {HOSTNAME: WORKER_CONFIGURATION}.

hello()

@classmethod
def hello(
from_node: string,
revoked: object = null
) - > object

Sends a hello greeting to workers to identify the current node and optionally synchronize revoked tasks.

Parameters

NameTypeDescription
from_nodestringThe name of the node sending the greeting.
revokedobject = nullOptional list of revoked tasks to synchronize with the workers.

Returns

TypeDescription
objectThe response from the workers acknowledging the greeting.

memsample()

@classmethod
def memsample() - > object

Return sample current RSS memory usage.

Returns

TypeDescription
objectA dictionary containing memory usage samples from workers.

memdump()

@classmethod
def memdump(
samples: integer = 10
) - > object

Dump statistics of previous memsample requests.

Parameters

NameTypeDescription
samplesinteger = 10The number of previous samples to include in the dump.

Returns

TypeDescription
objectA dictionary containing the history of memory samples.

objgraph()

@classmethod
def objgraph(
type: string = Request,
n: integer = 200,
max_depth: integer = 10
) - > object

Create graph of uncollected objects (memory-leak debugging).

Parameters

NameTypeDescription
typestring = RequestName of object to graph.
ninteger = 200Max number of objects to graph.
max_depthinteger = 10Traverse at most n levels deep.

Returns

TypeDescription
objectDictionary {'filename': FILENAME}