Generic process mailbox.
copyright: |
|
---|---|
license: | BSD, see LICENSE for more details. |
>>> mailbox = pidbox.Mailbox("celerybeat", type="direct")
>>> @mailbox.handler
>>> def reload_schedule(state, **kwargs):
... state["beat"].reload_schedule()
>>> @mailbox.handler
>>> def connection_info(state, **kwargs):
... return {"connection": state["connection"].info()}
>>> connection = kombu.BrokerConnection()
>>> state = {"beat": beat,
"connection": connection}
>>> consumer = mailbox(connection).Node(hostname).listen()
>>> try:
... while True:
... connection.drain_events(timeout=1)
... finally:
... consumer.cancel()
>>> mailbox.cast("reload_schedule") # cast is async.
>>> info = celerybeat.call("connection_info", timeout=1)
Name of application.
Connection (if bound).
Exchange type (usually direct, or fanout for broadcast).
mailbox exchange (init by constructor).
exchange to send replies to.
hostname of the node.
map of method name/handlers.
current context (passed on to handlers)
current channel.