This document describes Celery 2.4. For development docs, go here.
celery.events¶
celery.events¶
Events are messages sent for actions happening
in the worker (and clients if CELERY_SEND_TASK_SENT_EVENT
is enabled), used for monitoring purposes.
| copyright: |
|
|---|---|
| license: | BSD, see LICENSE for more details. |
-
celery.events.Event(type, _fields=None, **fields)¶ Create an event.
An event is a dictionary, the only required field is
type.
-
class
celery.events.EventDispatcher(connection=None, hostname=None, enabled=True, channel=None, buffer_while_offline=True, app=None, serializer=None)¶ Send events as messages.
Parameters: - connection – Connection to the broker.
- hostname – Hostname to identify ourselves as,
by default uses the hostname returned by
socket.gethostname(). - enabled – Set to
Falseto not actually publish any events, makingsend()a noop operation. - channel – Can be used instead of connection to specify an exact channel to use when sending events.
- buffer_while_offline – If enabled events will be buffered
while the connection is down.
flush()must be called as soon as the connection is re-established.
You need to
close()this after use.-
close()¶ Close the event dispatcher.
-
copy_buffer(other)¶
-
disable()¶
-
enable()¶
-
flush()¶
-
send(type, **fields)¶ Send event.
Parameters: - type – Kind of event.
- **fields – Event arguments.
-
class
celery.events.EventReceiver(connection, handlers=None, routing_key='#', node_id=None, app=None)¶ Capture events.
Parameters: - connection – Connection to the broker.
- handlers – Event handlers.
handlersis a dict of event types and their handlers, the special handler “*” captures all events that doesn’t have a handler.-
capture(limit=None, timeout=None, wakeup=True)¶ Open up a consumer capturing events.
This has to run in the main process, and it will never stop unless forced via
KeyboardInterruptorSystemExit.
-
consumer(*args, **kwds)¶ Create event consumer.
Warning
This creates a new channel that needs to be closed by calling consumer.channel.close().
-
drain_events(limit=None, timeout=None)¶
-
handlers= {}¶
-
itercapture(limit=None, timeout=None, wakeup=True)¶
-
process(type, event)¶ Process the received event by dispatching it to the appropriate handler.
-
wakeup_workers(channel=None)¶