]> granicus.if.org Git - python/commitdiff
Prevent test_queue from leaking: one worker thread was not stopped.
authorAmaury Forgeot d'Arc <amauryfa@gmail.com>
Tue, 1 Apr 2008 21:23:34 +0000 (21:23 +0000)
committerAmaury Forgeot d'Arc <amauryfa@gmail.com>
Tue, 1 Apr 2008 21:23:34 +0000 (21:23 +0000)
The version in trunk/ is correct; the problem with 3.0 is that
None cannot be used as a marker in a PriorityQueue, because it cannot be compared with ints.

Lib/test/test_queue.py

index 06e32ecd25235d1fa86c5241e530a179fe021bcd..8c961941f475ad38837bc4a15761ab207aa33446 100644 (file)
@@ -144,7 +144,7 @@ class BaseQueueTest(unittest.TestCase, BlockingTestMixin):
     def worker(self, q):
         while True:
             x = q.get()
-            if x is None:
+            if x < 0:
                 q.task_done()
                 return
             with self.cumlock:
@@ -160,7 +160,8 @@ class BaseQueueTest(unittest.TestCase, BlockingTestMixin):
         q.join()
         self.assertEquals(self.cum, sum(range(100)),
                           "q.join() did not block until all tasks were done")
-        q.put(None)         # instruct the threads to close
+        for i in (0,1):
+            q.put(-1)         # instruct the threads to close
         q.join()                # verify that you can join twice
 
     def test_queue_task_done(self):