Events - celery.events

celery.events.Event(type, **fields)

Create an event.

An event is a dictionary, the only required field is the type.

class celery.events.EventDispatcher(connection, hostname=None, enabled=True)

Send events as messages.

Parameters:
  • connection – Carrot connection.
  • hostname – Hostname to identify ourselves as, by default uses the hostname returned by socket.gethostname().
  • enabled – Set to False to not actually publish any events, making send() a noop operation.

You need to close() this after use.

close()

Close the event dispatcher.

disable()
enable()
send(type, **fields)

Send event.

Parameters:
  • type – Kind of event.
  • **fields – Event arguments.
class celery.events.EventReceiver(connection, handlers=None)

Capture events.

Parameters:
  • connection – Carrot connection.
  • handlers – Event handlers.

handlers` is a dict of event types and their handlers, the special handler "*`" captures all events that doesn’t have a handler.

capture(limit=None)

Open up a consumer capturing events.

This has to run in the main process, and it will never stop unless forced via KeyboardInterrupt or SystemExit.

consumer()
process(type, event)

Process the received event by dispatching it to the appropriate handler.

celery.events.create_event(type, fields)

Previous topic

Contrib: Abortable tasks - celery.contrib.abortable

Next topic

In-memory Representation of Cluster State - celery.events.state

This Page