Skip to content

Commit ab8d975

Browse files
committed
Remove queue-size tasks instead of setting to zero
1 parent 88f918d commit ab8d975

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

Lib/queue.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -238,9 +238,10 @@ def shutdown(self, immediate=False):
238238
with self.mutex:
239239
self.is_shutdown = True
240240
if immediate:
241+
n_items = self._qsize()
241242
while self._qsize():
242243
self._get()
243-
self.unfinished_tasks = 0
244+
self.unfinished_tasks -= n_items
244245
self.not_empty.notify_all()
245246
# release all blocked threads in `join()`
246247
self.all_tasks_done.notify_all()

0 commit comments

Comments
 (0)