[py-svn] r40003 - in py/branch/lessthread/py/execnet: . testing

hpk at codespeak.net hpk at codespeak.net
Tue Mar 6 22:23:30 CET 2007


Author: hpk
Date: Tue Mar  6 22:23:30 2007
New Revision: 40003

Modified:
   py/branch/lessthread/py/execnet/gateway.py
   py/branch/lessthread/py/execnet/testing/test_gateway.py
Log:
refine thread support a bit


Modified: py/branch/lessthread/py/execnet/gateway.py
==============================================================================
--- py/branch/lessthread/py/execnet/gateway.py	(original)
+++ py/branch/lessthread/py/execnet/gateway.py	Tue Mar  6 22:23:30 2007
@@ -158,8 +158,9 @@
                 if item is None:
                     self._stopsend()
                     break
-                stop = self._executetask(item) # could be done in an exec thread 
-                if stop:
+                try:
+                    self._executetask(item)
+                except StopExecLoop:
                     break
         finally:
             self._trace("_servemain finished") 
@@ -171,6 +172,8 @@
             remote_exec() invocations to allow concurrent
             execution. 
         """
+        if hasattr(self, '_remotechannelthread'):
+            raise IOError("remote threads already running")
         from py.__.thread import pool
         source = py.code.Source(pool, """
             execpool = WorkerPool(maxthreads=%r)
@@ -182,7 +185,7 @@
                     raise StopExecLoop
                 execpool.dispatch(gw._executetask, task)
         """ % num)
-        self.remote_exec(source)
+        self._remotechannelthread = self.remote_exec(source)
 
     def _executetask(self, item):
         """ execute channel/source items. """
@@ -203,7 +206,7 @@
             pass 
         except StopExecLoop:
             channel.close()
-            return True
+            raise
         except:
             excinfo = exc_info()
             l = traceback.format_exception(*excinfo)

Modified: py/branch/lessthread/py/execnet/testing/test_gateway.py
==============================================================================
--- py/branch/lessthread/py/execnet/testing/test_gateway.py	(original)
+++ py/branch/lessthread/py/execnet/testing/test_gateway.py	Tue Mar  6 22:23:30 2007
@@ -498,6 +498,10 @@
     assert res == 42
     gw.exit()
     
- 
+def test_threads_twice():
+    gw = py.execnet.PopenGateway()
+    gw.remote_init_threads(3)
+    py.test.raises(IOError, gw.remote_init_threads, 3)
+    gw.exit() 
     
     


More information about the py-svn mailing list