API Reference#
- exception QueueException#
Base class of all the queue-related exceptions.
- exception WouldBlock#
Raised by X_nowait functions if X would block.
- exception Closed#
Occurs when:
one tries to get an item from a queue that is in the
CLOSED
state.one tries to get an item from an empty queue that is in the
HALF_CLOSED
state.one tries to put an item into a queue that is in the
CLOSED
orHALF_CLOSED
state.
- class Queue(*, capacity: int | None = None, order: Literal['fifo', 'lifo', 'small-first'] = 'fifo')#
- Parameters:
capacity – Cannot be zero. Unlimited if None.
- put_nowait(item)#
queue.put_nowait(item)
- half_close()#
Partially closes the queue. No further putting-opeations are allowed.
- close()#
Fully closes the queue. No further putting/getting-operations are allowed. All items in the queue are discarded.
- async __aiter__()#
Keeps retrieving items from the queue until it is closed.
async for item in queue: ...
which is equivalent to:
try: while True: item = await queue.get() ... except Closed: pass