(Latest Version)

morpheus.utils.producer_consumer_queue.AsyncIOProducerConsumerQueue

class AsyncIOProducerConsumerQueue(maxsize=0, *, loop=None)[source]

Bases: asyncio.queues.Queue, Generic[morpheus.utils.producer_consumer_queue._T]

Custom queue.Queue implementation which supports closing and uses recursive locks

Attributes
maxsize

Number of items allowed in the queue.

Methods

close()

Close the queue.

empty()

Return True if the queue is empty, False otherwise.

full()

Return True if there are maxsize items in the queue.

get()

Remove and return an item from the queue.

get_nowait()

Remove and return an item from the queue.

is_closed()

Check if the queue is closed.

join()

Block until all items in the queue have been gotten and processed.

put(item)

Put an item into the queue.

put_nowait(item)

Put an item into the queue without blocking.

qsize()

Number of items in the queue.

task_done()

Indicate that a formerly enqueued task is complete.

async close()[source]

Close the queue.

empty()[source]

Return True if the queue is empty, False otherwise.

full()[source]

Return True if there are maxsize items in the queue.

Note: if the Queue was initialized with maxsize=0 (the default), then full() is never True.

async get()[source]

Remove and return an item from the queue.

If queue is empty, wait until an item is available.

get_nowait()[source]

Remove and return an item from the queue.

Return an item if one is immediately available, else raise QueueEmpty.

is_closed()[source]

Check if the queue is closed.

async join()[source]

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.

property maxsize

Number of items allowed in the queue.

async put(item)[source]

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.

put_nowait(item)[source]

Put an item into the queue without blocking.

If no free slot is immediately available, raise QueueFull.

qsize()[source]

Number of items in the queue.

task_done()[source]

Indicate that a formerly enqueued task is complete.

Used by queue consumers. For each get() used to fetch a task, a subsequent call to task_done() tells the queue that the processing on the task is complete.

If a join() is currently blocking, it will resume when all items have been processed (meaning that a task_done() call was received for every item that had been put() into the queue).

Raises ValueError if called more times than there were items placed in the queue.

© Copyright 2023, NVIDIA. Last updated on Apr 11, 2023.