mirror of
https://github.com/python/cpython.git
synced 2025-11-13 23:46:24 +00:00
Fix a conversion mistake that caused test_queue to fail intermittently.
This commit is contained in:
parent
ee29c3f2a8
commit
cafb710711
1 changed files with 4 additions and 4 deletions
|
|
@ -138,13 +138,13 @@ class BaseQueueTest(unittest.TestCase, BlockingTestMixin):
|
||||||
|
|
||||||
def worker(self, q):
|
def worker(self, q):
|
||||||
while True:
|
while True:
|
||||||
self.x = q.get()
|
x = q.get()
|
||||||
if self.x is None:
|
if x is None:
|
||||||
q.task_done()
|
q.task_done()
|
||||||
return
|
return
|
||||||
self.cumlock.acquire()
|
self.cumlock.acquire()
|
||||||
try:
|
try:
|
||||||
self.cum += self.x
|
self.cum += x
|
||||||
finally:
|
finally:
|
||||||
self.cumlock.release()
|
self.cumlock.release()
|
||||||
q.task_done()
|
q.task_done()
|
||||||
|
|
@ -157,7 +157,7 @@ class BaseQueueTest(unittest.TestCase, BlockingTestMixin):
|
||||||
q.put(i)
|
q.put(i)
|
||||||
q.join()
|
q.join()
|
||||||
self.assertEquals(self.cum, sum(range(100)),
|
self.assertEquals(self.cum, sum(range(100)),
|
||||||
"q.join() did not block until all tasks were done")
|
"q.join() did not block until all tasks were done")
|
||||||
for i in (0,1):
|
for i in (0,1):
|
||||||
q.put(None) # instruct the threads to close
|
q.put(None) # instruct the threads to close
|
||||||
q.join() # verify that you can join twice
|
q.join() # verify that you can join twice
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue