aiq.utils.producer_consumer_queue#
Attributes#
Exceptions#
Exception raised when the queue is closed |
Classes#
Custom queue.Queue implementation which supports closing and uses recursive locks |
Module Contents#
- _T#
- exception QueueClosed#
Bases:
Exception
Exception raised when the queue is closed
Initialize self. See help(type(self)) for accurate signature.
- class AsyncIOProducerConsumerQueue(maxsize=0)#
Bases:
asyncio.Queue
,Generic
[_T
]Custom queue.Queue implementation which supports closing and uses recursive locks
- _closed#
- _is_closed = False#
- async join()#
Block until all items in the queue have been gotten and processed.
The count of unfinished tasks goes up whenever an item is added to the queue. The count goes down whenever a consumer calls task_done() to indicate that the item was retrieved and all work on it is complete. When the count of unfinished tasks drops to zero, join() unblocks.
- async put(item)#
Put an item into the queue.
Put an item into the queue. If the queue is full, wait until a free slot is available before adding item.
- async get() _T #
Remove and return an item from the queue.
If queue is empty, wait until an item is available.
- put_blocking(item: _T)#
Synchronously block until the item can be put. This method creates or uses an event loop internally to call the async put(). If the queue is closed, it raises QueueClosed.
- NOTE: If you already have an event loop running in this same thread, calling
run_until_complete
can cause conflicts or an error. Typically, you only want to do this from a pure synchronous environment.
- async close()#
Close the queue.