Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 6f01015

Browse filesBrowse files
committed
integration of shudown transition in shutdown method
Change "shutdown_immediate" to "shutdown-immediate"
1 parent 06775bb commit 6f01015
Copy full SHA for 6f01015

File tree

Expand file treeCollapse file tree

2 files changed

+9
-3
lines changed
Filter options
Expand file treeCollapse file tree

2 files changed

+9
-3
lines changed

‎Lib/asyncio/queues.py

Copy file name to clipboardExpand all lines: Lib/asyncio/queues.py
+5-2Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -261,19 +261,22 @@ def shutdown(self, immediate=False):
261261
All blocked callers of put() will be unblocked, and also get()
262262
and join() if 'immediate'. The QueueShutDown exception is raised.
263263
"""
264+
if self._shutdown_state is _QueueState.SHUTDOWN_IMMEDIATE:
265+
return
266+
264267
if immediate:
265268
self._shutdown_state = _QueueState.SHUTDOWN_IMMEDIATE
266269
while self._getters:
267270
getter = self._getters.popleft()
268271
if not getter.done():
269272
getter.set_result(None)
270273
else:
271-
self._shutdown_state = _QueueState.SHUTDOWN
274+
self._shutdown_state = _QueueState.SHUTDOWN
272275
while self._putters:
273276
putter = self._putters.popleft()
274277
if not putter.done():
275278
putter.set_result(None)
276-
# Release 'joined' tasks/coros
279+
# Release 'blocked' tasks/coros via `.join()`
277280
self._finished.set()
278281

279282

‎Lib/queue.py

Copy file name to clipboardExpand all lines: Lib/queue.py
+4-1Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ class ShutDown(Exception):
3333
class _QueueState(enum.Enum):
3434
ALIVE = "alive"
3535
SHUTDOWN = "shutdown"
36-
SHUTDOWN_IMMEDIATE = "shutdown_immediate"
36+
SHUTDOWN_IMMEDIATE = "shutdown-immediate"
3737

3838

3939
class Queue:
@@ -244,6 +244,9 @@ def shutdown(self, immediate=False):
244244
and join() if 'immediate'. The ShutDown exception is raised.
245245
'''
246246
with self.mutex:
247+
if self.shutdown_state is _QueueState.SHUTDOWN_IMMEDIATE:
248+
return
249+
247250
if immediate:
248251
self.shutdown_state = _QueueState.SHUTDOWN_IMMEDIATE
249252
self.not_empty.notify_all()

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.