File tree Expand file tree Collapse file tree 2 files changed +7
-8
lines changed Expand file tree Collapse file tree 2 files changed +7
-8
lines changed Original file line number Diff line number Diff line change @@ -241,7 +241,7 @@ def shutdown(self, immediate=False):
241
241
n_items = self ._qsize ()
242
242
while self ._qsize ():
243
243
self ._get ()
244
- self .unfinished_tasks -= n_items
244
+ self .unfinished_tasks = max ( self . unfinished_tasks - n_items , 0 )
245
245
self .not_empty .notify_all ()
246
246
# release all blocked threads in `join()`
247
247
self .all_tasks_done .notify_all ()
Original file line number Diff line number Diff line change @@ -575,14 +575,13 @@ def _shutdown_put_join(self, immediate):
575
575
for func , params in thrds :
576
576
threads .append (threading .Thread (target = func , args = params ))
577
577
threads [- 1 ].start ()
578
- if not immediate or immediate : # TODO: dedent (minimising Git diff)
579
- self .assertEqual (q .unfinished_tasks , nb )
580
- for i in range (nb ):
581
- t = threading .Thread (target = q .task_done )
582
- t .start ()
583
- threads .append (t )
584
- go .set ()
578
+ self .assertEqual (q .unfinished_tasks , nb )
579
+ for i in range (nb ):
580
+ t = threading .Thread (target = q .task_done )
581
+ t .start ()
582
+ threads .append (t )
585
583
q .shutdown (immediate )
584
+ go .set ()
586
585
for t in threads :
587
586
t .join ()
588
587
You can’t perform that action at this time.
0 commit comments