Closed pkolchanov closed 7 years ago
Because it implements the sync
API for queue polling. It's part of AMQP spec, see https://www.rabbitmq.com/amqp-0-9-1-reference.html#basic.get
For async
AMQP API you can use the queue.consume
to register a callback for messages and use it to get somehow an API like you want:
from asyncio import Queue
async def process_asynqp_queue(asynqp_queue):
msg_buffer = Queue()
await asynqp_queue.consume(msg_buffer.put_nowait)
while True:
msg = await msg_buffer.get()
Of course a proper implementation with all error handling and reconnects is more troublesome thou...
Why
get()
method returnsNone
if there were no messages on the queue instead of wait them?