File tree Expand file tree Collapse file tree 2 files changed +9
-3
lines changed
Filter options
Expand file tree Collapse file tree 2 files changed +9
-3
lines changed
Original file line number Diff line number Diff line change @@ -261,19 +261,22 @@ def shutdown(self, immediate=False):
261
261
All blocked callers of put() will be unblocked, and also get()
262
262
and join() if 'immediate'. The QueueShutDown exception is raised.
263
263
"""
264
+ if self ._shutdown_state is _QueueState .SHUTDOWN_IMMEDIATE :
265
+ return
266
+
264
267
if immediate :
265
268
self ._shutdown_state = _QueueState .SHUTDOWN_IMMEDIATE
266
269
while self ._getters :
267
270
getter = self ._getters .popleft ()
268
271
if not getter .done ():
269
272
getter .set_result (None )
270
273
else :
271
- self ._shutdown_state = _QueueState .SHUTDOWN
274
+ self ._shutdown_state = _QueueState .SHUTDOWN
272
275
while self ._putters :
273
276
putter = self ._putters .popleft ()
274
277
if not putter .done ():
275
278
putter .set_result (None )
276
- # Release 'joined ' tasks/coros
279
+ # Release 'blocked ' tasks/coros via `.join()`
277
280
self ._finished .set ()
278
281
279
282
Original file line number Diff line number Diff line change @@ -33,7 +33,7 @@ class ShutDown(Exception):
33
33
class _QueueState (enum .Enum ):
34
34
ALIVE = "alive"
35
35
SHUTDOWN = "shutdown"
36
- SHUTDOWN_IMMEDIATE = "shutdown_immediate "
36
+ SHUTDOWN_IMMEDIATE = "shutdown-immediate "
37
37
38
38
39
39
class Queue :
@@ -244,6 +244,9 @@ def shutdown(self, immediate=False):
244
244
and join() if 'immediate'. The ShutDown exception is raised.
245
245
'''
246
246
with self .mutex :
247
+ if self .shutdown_state is _QueueState .SHUTDOWN_IMMEDIATE :
248
+ return
249
+
247
250
if immediate :
248
251
self .shutdown_state = _QueueState .SHUTDOWN_IMMEDIATE
249
252
self .not_empty .notify_all ()
You can’t perform that action at this time.
0 commit comments