mirror of
https://github.com/python/cpython.git
synced 2025-09-14 20:56:06 +00:00
Don't decrement below zero. And add more tests.
This commit is contained in:
parent
ccc7bb4ef2
commit
c4e94b90a8
2 changed files with 19 additions and 4 deletions
|
@ -56,11 +56,12 @@ class Queue:
|
|||
"""
|
||||
self.all_tasks_done.acquire()
|
||||
try:
|
||||
self.unfinished_tasks = unfinished = self.unfinished_tasks - 1
|
||||
unfinished = self.unfinished_tasks - 1
|
||||
if unfinished <= 0:
|
||||
if unfinished < 0:
|
||||
raise ValueError('task_done() called too many times')
|
||||
self.all_tasks_done.notifyAll()
|
||||
self.unfinished_tasks = unfinished
|
||||
finally:
|
||||
self.all_tasks_done.release()
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue