Common Utilities.
Convenience class used to define broadcast queues.
Every queue instance will have a unique name, and both the queue and exchange is configured with auto deletion.
Parameters: |
|
---|
Generate a unique id, having - hopefully - a very small chance of collision.
For now this is provided by uuid.uuid4().
Send reply for request.
Parameters: |
|
---|
Generator collecting replies from queue
Ensures function performing broker commands completes despite intermittent connection failures.
Best practice generator wrapper around Connection.drain_events.
Able to drain events forever, with a limit, and optionally ignoring timeout errors (a timeout of 1 is often used in environments where the socket can get “stuck”, and is a best practice for Kombu consumers).
Examples
eventloop is a generator:
from kombu.common import eventloop
def run(connection):
it = eventloop(connection, timeout=1, ignore_timeouts=True)
next(it) # one event consumed, or timed out.
for _ in eventloop(connection, timeout=1, ignore_timeouts=True):
pass # loop forever.
It also takes an optional limit parameter, and timeout errors are propagated by default:
for _ in eventloop(connection, limit=1, timeout=1):
pass
See also
itermessages(), which is an event loop bound to one or more consumers, that yields any messages received.