This document describes an older version of Celery (2.5). For the latest stable version please go here.

celery.task.control

celery.task.control

Client for worker remote control commands. Server implementation is in celery.worker.control.

copyright:
  1. 2009 - 2012 by Ask Solem.
license:

BSD, see LICENSE for more details.

class celery.task.control.Control(app)
class Mailbox(namespace, type='direct', connection=None)
Node(hostname=None, state=None, channel=None, handlers=None)
abcast(command, kwargs={})
call(destination, command, kwargs={}, timeout=None, callback=None, channel=None)
cast(destination, command, kwargs={})
connection = None
exchange = None
exchange_fmt = '%s.pidbox'
get_queue(hostname)
get_reply_queue(ticket)
multi_call(command, kwargs={}, timeout=1, limit=None, callback=None, channel=None)
namespace = None
node_cls

alias of Node

reply_exchange = None
reply_exchange_fmt = 'reply.%s.pidbox'
type = 'direct'
Control.broadcast(command, arguments=None, destination=None, connection=None, connect_timeout=None, reply=False, timeout=1, limit=None, callback=None, channel=None)

Broadcast a control command to the celery workers.

Parameters:
  • command – Name of command to send.
  • arguments – Keyword arguments for the command.
  • destination – If set, a list of the hosts to send the command to, when empty broadcast to all workers.
  • connection – Custom broker connection to use, if not set, a connection will be established automatically.
  • connect_timeout – Timeout for new connection if a custom connection is not provided.
  • reply – Wait for and return the reply.
  • timeout – Timeout in seconds to wait for the reply.
  • limit – Limit number of replies.
  • callback – Callback called immediately for each reply received.
Control.discard_all(connection=None, connect_timeout=None)

Discard all waiting tasks.

This will ignore all tasks waiting for execution, and they will be deleted from the messaging server.

Returns:the number of tasks discarded.
Control.inspect(destination=None, timeout=1, callback=None)
Control.ping(destination=None, timeout=1, **kwargs)

Ping workers.

Returns answer from alive workers.

Parameters:
  • destination – If set, a list of the hosts to send the command to, when empty broadcast to all workers.
  • connection – Custom broker connection to use, if not set, a connection will be established automatically.
  • connect_timeout – Timeout for new connection if a custom connection is not provided.
  • reply – Wait for and return the reply.
  • timeout – Timeout in seconds to wait for the reply.
  • limit – Limit number of replies.
Control.rate_limit(task_name, rate_limit, destination=None, **kwargs)

Set rate limit for task by type.

Parameters:
  • task_name – Name of task to change rate limit for.
  • rate_limit – The rate limit as tasks per second, or a rate limit string (“100/m”, etc. see celery.task.base.Task.rate_limit for more information).
  • destination – If set, a list of the hosts to send the command to, when empty broadcast to all workers.
  • connection – Custom broker connection to use, if not set, a connection will be established automatically.
  • connect_timeout – Timeout for new connection if a custom connection is not provided.
  • reply – Wait for and return the reply.
  • timeout – Timeout in seconds to wait for the reply.
  • limit – Limit number of replies.
Control.revoke(task_id, destination=None, terminate=False, signal='SIGTERM', **kwargs)

Revoke a task by id.

If a task is revoked, the workers will ignore the task and not execute it after all.

Parameters:
  • task_id – Id of the task to revoke.
  • terminate – Also terminate the process currently working on the task (if any).
  • signal – Name of signal to send to process if terminate. Default is TERM.
  • destination – If set, a list of the hosts to send the command to, when empty broadcast to all workers.
  • connection – Custom broker connection to use, if not set, a connection will be established automatically.
  • connect_timeout – Timeout for new connection if a custom connection is not provided.
  • reply – Wait for and return the reply.
  • timeout – Timeout in seconds to wait for the reply.
  • limit – Limit number of replies.
Control.time_limit(task_name, soft=None, hard=None, **kwargs)

Set time limits for task by type.

Parameters:
  • task_name – Name of task to change time limits for.
  • soft – New soft time limit (in seconds).
  • hard – New hard time limit (in seconds).

Any additional keyword arguments are passed on to broadcast().

class celery.task.control.Inspect(control, destination=None, timeout=1, callback=None)
active(safe=False)
active_queues()
add_consumer(queue, exchange=None, exchange_type='direct', routing_key=None, **options)
cancel_consumer(queue, **kwargs)
disable_events()
enable_events()
ping()
registered()
registered_tasks()
reserved(safe=False)
revoked()
scheduled(safe=False)
stats()
celery.task.control.flatten_reply(reply)

Previous topic

celery.actors

Next topic

celery.task.http

This Page