Skip to content

Commit af1744e

Browse files
committed
Update asynico main docs
1 parent 6740c3f commit af1744e

File tree

1 file changed

+25
-12
lines changed

1 file changed

+25
-12
lines changed

Doc/library/asyncio-queue.rst

Lines changed: 25 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -102,17 +102,33 @@ Queue
102102

103103
.. method:: shutdown(immediate=False)
104104

105-
Shut down the queue, making :meth:`~Queue.get` and :meth:`~Queue.put`
106-
raise :exc:`QueueShutDown`.
105+
Put a :class:`Queue` instance into a shutdown mode.
107106

108-
By default, :meth:`~Queue.get` on a shut down queue will only
109-
raise once the queue is empty. Set *immediate* to true to make
110-
:meth:`~Queue.get` raise immediately instead.
107+
The queue can no longer grow.
108+
Future calls to :meth:`~Queue.put` raise :exc:`ShutDown`.
109+
Currently blocked callers of :meth:`~Queue.put` will be unblocked
110+
and will raise :exc:`ShutDown` in the formerly blocked thread.
111111

112-
All blocked callers of :meth:`~Queue.put` and :meth:`~Queue.get`
113-
will be unblocked. If *immediate* is true, a task will be marked
114-
as done for each remaining item in the queue, which may unblock
115-
callers of :meth:`~Queue.join`.
112+
If *immediate* is false (the default), the queue can be wound
113+
down normally with calls :meth:`~Queue.get` to extract tasks
114+
that have already been loaded.
115+
116+
And if :meth:`~Queue.task_done` is called for each remaining task, a
117+
pending :meth:`~Queue.join` will be unblocked normally.
118+
119+
Once the queue is empty, future calls to :meth:`~Queue.get` will
120+
raise :exc:`ShutDown`.
121+
122+
If *immediate* is true, the queue is terminated immediately.
123+
The queue is drained to be completely empty. All callers of
124+
:meth:`~Queue.join` are unblocked regardless of the number
125+
of unfinished tasks. Blocked callers of :meth:`~Queue.get`
126+
are unblocked and will raise :exc:`ShutDown` because the
127+
queue is empty.
128+
129+
Use caution when using :meth:`~Queue.join` with *immediate* set
130+
to true. This unblocks the join even when no work has been done
131+
on the tasks, violating the usual invariant for joining a queue.
116132

117133
.. versionadded:: 3.13
118134

@@ -129,9 +145,6 @@ Queue
129145
call was received for every item that had been :meth:`~Queue.put`
130146
into the queue).
131147

132-
``shutdown(immediate=True)`` calls :meth:`task_done` for each
133-
remaining item in the queue.
134-
135148
Raises :exc:`ValueError` if called more times than there were
136149
items placed in the queue.
137150

0 commit comments

Comments
 (0)