This document is for Kombu's development version, which can be significantly different from previous releases. Get the stable docs here: 5.0.
Pidbox- kombu.pidbox
¶
通用进程邮箱。
引言¶
创建应用程序邮箱¶
>>> 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.Connection()
>>> 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)
邮箱¶
- class kombu.pidbox.Mailbox(namespace, type='direct', connection=None, clock=None, accept=None, serializer=None, producer_pool=None, queue_ttl=None, queue_expires=None, reply_queue_ttl=None, reply_queue_expires=10.0)[源代码]¶
进程邮箱。
- namespace = None¶
应用程序的名称。
- connection = None¶
连接(如果绑定)。
- type = 'direct'¶
交换类型(通常为直接交换,或用于广播的扇形传出)。
- exchange = None¶
邮箱交换(由构造函数初始化)。
- reply_exchange = None¶
要向其发送回复的Exchange。