academy.exchange.queue¶
AsyncQueue
¶
Bases: Generic[T]
Simple async queue.
This is a simple backport of Python 3.13 queues which have a shutdown method and exception type.
Source code in academy/exchange/queue.py
close
async
¶
close(immediate: bool = False) -> None
Close the queue.
This will cause get
and put
to raise QueueClosedError
.
Parameters:
-
immediate
(bool
, default:False
) –Close the queue immediately, rather than once the queue is empty.
Source code in academy/exchange/queue.py
get
async
¶
Remove and return the next item from the queue (blocking).
Queue
¶
Bases: Generic[T]
Simple queue.
This is a simple backport of Python 3.13 queues which have a shutdown method and exception type.
Source code in academy/exchange/queue.py
close
¶
close(immediate: bool = False) -> None
Close the queue.
This will cause get
and put
to raise QueueClosedError
.
Parameters:
-
immediate
(bool
, default:False
) –Close the queue immediately, rather than once the queue is empty.
Source code in academy/exchange/queue.py
get
¶
get(timeout: float | None = None) -> T
Remove and return the next item from the queue (blocking).
Parameters:
-
timeout
(float | None
, default:None
) –Block at most
timeout
seconds.
Raises:
-
TimeoutError
–if no item was available within
timeout
seconds. -
QueueClosedError
–if the queue was closed.
Source code in academy/exchange/queue.py
put
¶
Put an item on the queue.
Parameters:
-
item
(T
) –The item to put on the queue.
Raises:
-
QueueClosedError
–if the queue was closed.