mirror of
https://github.com/python/cpython.git
synced 2025-11-24 12:20:42 +00:00
[3.14] Fix Queue.shutdown docs for condition to unblock a join (gh-137088) (#141073)
(cherry picked from commit ea06ae5b5e)
Co-authored-by: Raymond Hettinger <rhettinger@users.noreply.github.com>
This commit is contained in:
parent
9878611f28
commit
12847bfff7
4 changed files with 18 additions and 12 deletions
|
|
@ -120,9 +120,10 @@ Queue
|
||||||
raise :exc:`QueueShutDown`.
|
raise :exc:`QueueShutDown`.
|
||||||
|
|
||||||
If *immediate* is true, the queue is terminated immediately.
|
If *immediate* is true, the queue is terminated immediately.
|
||||||
The queue is drained to be completely empty. All callers of
|
The queue is drained to be completely empty and the count
|
||||||
:meth:`~Queue.join` are unblocked regardless of the number
|
of unfinished tasks is reduced by the number of tasks drained.
|
||||||
of unfinished tasks. Blocked callers of :meth:`~Queue.get`
|
If unfinished tasks is zero, callers of :meth:`~Queue.join`
|
||||||
|
are unblocked. Also, blocked callers of :meth:`~Queue.get`
|
||||||
are unblocked and will raise :exc:`QueueShutDown` because the
|
are unblocked and will raise :exc:`QueueShutDown` because the
|
||||||
queue is empty.
|
queue is empty.
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -256,9 +256,10 @@ until empty or terminated immediately with a hard shutdown.
|
||||||
raise :exc:`ShutDown`.
|
raise :exc:`ShutDown`.
|
||||||
|
|
||||||
If *immediate* is true, the queue is terminated immediately.
|
If *immediate* is true, the queue is terminated immediately.
|
||||||
The queue is drained to be completely empty. All callers of
|
The queue is drained to be completely empty and the count
|
||||||
:meth:`~Queue.join` are unblocked regardless of the number
|
of unfinished tasks is reduced by the number of tasks drained.
|
||||||
of unfinished tasks. Blocked callers of :meth:`~Queue.get`
|
If unfinished tasks is zero, callers of :meth:`~Queue.join`
|
||||||
|
are unblocked. Also, blocked callers of :meth:`~Queue.get`
|
||||||
are unblocked and will raise :exc:`ShutDown` because the
|
are unblocked and will raise :exc:`ShutDown` because the
|
||||||
queue is empty.
|
queue is empty.
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -253,9 +253,11 @@ class Queue(mixins._LoopBoundMixin):
|
||||||
By default, gets will only raise once the queue is empty. Set
|
By default, gets will only raise once the queue is empty. Set
|
||||||
'immediate' to True to make gets raise immediately instead.
|
'immediate' to True to make gets raise immediately instead.
|
||||||
|
|
||||||
All blocked callers of put() and get() will be unblocked. If
|
All blocked callers of put() and get() will be unblocked.
|
||||||
'immediate', unblock callers of join() regardless of the
|
|
||||||
number of unfinished tasks.
|
If 'immediate', the queue is drained and unfinished tasks
|
||||||
|
is reduced by the number of drained tasks. If unfinished tasks
|
||||||
|
is reduced to zero, callers of Queue.join are unblocked.
|
||||||
"""
|
"""
|
||||||
self._is_shutdown = True
|
self._is_shutdown = True
|
||||||
if immediate:
|
if immediate:
|
||||||
|
|
|
||||||
|
|
@ -236,9 +236,11 @@ class Queue:
|
||||||
By default, gets will only raise once the queue is empty. Set
|
By default, gets will only raise once the queue is empty. Set
|
||||||
'immediate' to True to make gets raise immediately instead.
|
'immediate' to True to make gets raise immediately instead.
|
||||||
|
|
||||||
All blocked callers of put() and get() will be unblocked. If
|
All blocked callers of put() and get() will be unblocked.
|
||||||
'immediate', callers of join() are unblocked regardless of
|
|
||||||
the number of unfinished tasks.
|
If 'immediate', the queue is drained and unfinished tasks
|
||||||
|
is reduced by the number of drained tasks. If unfinished tasks
|
||||||
|
is reduced to zero, callers of Queue.join are unblocked.
|
||||||
'''
|
'''
|
||||||
with self.mutex:
|
with self.mutex:
|
||||||
self.is_shutdown = True
|
self.is_shutdown = True
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue