summaryrefslogtreecommitdiffstats
path: root/Doc/library/asyncio-queue.rst
diff options
context:
space:
mode:
Diffstat (limited to 'Doc/library/asyncio-queue.rst')
-rw-r--r--Doc/library/asyncio-queue.rst31
1 files changed, 31 insertions, 0 deletions
diff --git a/Doc/library/asyncio-queue.rst b/Doc/library/asyncio-queue.rst
index d86fbc2..030d431 100644
--- a/Doc/library/asyncio-queue.rst
+++ b/Doc/library/asyncio-queue.rst
@@ -62,6 +62,9 @@ Queue
Remove and return an item from the queue. If queue is empty,
wait until an item is available.
+ Raises :exc:`QueueShutDown` if the queue has been shut down and
+ is empty, or if the queue has been shut down immediately.
+
.. method:: get_nowait()
Return an item if one is immediately available, else raise
@@ -82,6 +85,8 @@ Queue
Put an item into the queue. If the queue is full, wait until a
free slot is available before adding the item.
+ Raises :exc:`QueueShutDown` if the queue has been shut down.
+
.. method:: put_nowait(item)
Put an item into the queue without blocking.
@@ -92,6 +97,21 @@ Queue
Return the number of items in the queue.
+ .. method:: shutdown(immediate=False)
+
+ Shut down the queue, making :meth:`~Queue.get` and :meth:`~Queue.put`
+ raise :exc:`QueueShutDown`.
+
+ By default, :meth:`~Queue.get` on a shut down queue will only
+ raise once the queue is empty. Set *immediate* to true to make
+ :meth:`~Queue.get` raise immediately instead.
+
+ All blocked callers of :meth:`~Queue.put` will be unblocked. If
+ *immediate* is true, also unblock callers of :meth:`~Queue.get`
+ and :meth:`~Queue.join`.
+
+ .. versionadded:: 3.13
+
.. method:: task_done()
Indicate that a formerly enqueued task is complete.
@@ -105,6 +125,9 @@ Queue
call was received for every item that had been :meth:`~Queue.put`
into the queue).
+ ``shutdown(immediate=True)`` calls :meth:`task_done` for each
+ remaining item in the queue.
+
Raises :exc:`ValueError` if called more times than there were
items placed in the queue.
@@ -145,6 +168,14 @@ Exceptions
on a queue that has reached its *maxsize*.
+.. exception:: QueueShutDown
+
+ Exception raised when :meth:`~Queue.put` or :meth:`~Queue.get` is
+ called on a queue which has been shut down.
+
+ .. versionadded:: 3.13
+
+
Examples
========