Queue
FIFO queues with blocking and non-blocking operations.
PriorityQueue
Bases: Queue
Queue that serves items in sorted (ascending) order.
Uses bisect.insort to maintain the internal list in sorted order. Items must be comparable.
get()
Return an Event whose value is the next dequeued item.
is_empty()
True if the queue has no items.
is_full()
True if the queue is at capacity.
put(item)
Return an Event that resolves to True when item is enqueued.
Delivers directly to a waiting getter if one exists, adds to the queue if there is capacity, or blocks until capacity becomes available.
size()
Number of items currently in the queue.
try_get()
Remove and return the next item, or raise QueueEmpty.
try_put(item)
Add item to the queue, or raise QueueFull.
Queue
FIFO queue with optional maximum capacity.
Blocking operations (get, put) return an Event; await it for the result. Non-blocking operations (try_get, try_put) raise on failure.
get()
Return an Event whose value is the next dequeued item.
is_empty()
True if the queue has no items.
is_full()
True if the queue is at capacity.
put(item)
Return an Event that resolves to True when item is enqueued.
Delivers directly to a waiting getter if one exists, adds to the queue if there is capacity, or blocks until capacity becomes available.
size()
Number of items currently in the queue.
try_get()
Remove and return the next item, or raise QueueEmpty.
try_put(item)
Add item to the queue, or raise QueueFull.
QueueEmpty
Bases: Exception
Raised by Queue.try_get() when the queue is empty.
QueueFull
Bases: Exception
Raised by Queue.try_put() when the queue is at capacity.