[py-svn] r11512 - in py/dist/py/thread: . testing

jan at codespeak.net jan at codespeak.net
Wed Apr 27 14:27:21 CEST 2005


Author: jan
Date: Wed Apr 27 14:27:21 2005
New Revision: 11512

Modified:
   py/dist/py/thread/pool.py
   py/dist/py/thread/testing/test_pool.py
Log:
fix bug in py/thread/pool.py

* WorkerPool calls WorkerThread.stop() without removing the WorkerThread 
from WorkerPool._ready -> an AssertionError is raised in pool.py line 56

* WorkerThread.stop adds SystemExit to the queue instead of a Reply instance ->
unpacking raises an error



Modified: py/dist/py/thread/pool.py
==============================================================================
--- py/dist/py/thread/pool.py	(original)
+++ py/dist/py/thread/pool.py	Wed Apr 27 14:27:21 2005
@@ -52,7 +52,9 @@
     def run(self): 
         try: 
             while 1: 
-                reply = self._queue.get() 
+                reply = self._queue.get()
+                if reply is SystemExit:
+                    break
                 assert self not in self._pool._ready 
                 task = reply.task 
                 try: 

Modified: py/dist/py/thread/testing/test_pool.py
==============================================================================
--- py/dist/py/thread/testing/test_pool.py	(original)
+++ py/dist/py/thread/testing/test_pool.py	Wed Apr 27 14:27:21 2005
@@ -70,6 +70,8 @@
     pool.join(timeout=0.1) 
 
 def test_pool_clean_shutdown():
+    from py.__.test.tool.outerrcapture import SimpleOutErrCapture
+    capture = SimpleOutErrCapture() 
     pool = WorkerPool()
     def f():
         pass
@@ -79,3 +81,7 @@
     pool.join(timeout=1.0)
     assert not pool._alive
     assert not pool._ready
+    out, err = capture.reset()
+    print out
+    print >>sys.stderr, err
+    assert err == ''



More information about the pytest-commit mailing list