[Twisted-Python] [patch] 2/4 processEnded no thread callback

Andrea Arcangeli andrea at cpushare.com
Wed May 17 08:31:56 MDT 2006


I noticed processEnded is called by threads. This generates a subtle
race condition for most code (or at least for my code). The fact
processEnded is called from threads isn't documented anywhere and so I
prefer to be safe than sorry since I assume most code is written
thinking processEnded will run in the usual serialized context and not
in a parallel racy thread.

diff -r 493b5c24e0f3 twisted/internet/posixbase.py
--- a/twisted/internet/posixbase.py	Tue May 16 04:57:00 2006 +0000
+++ b/twisted/internet/posixbase.py	Wed May 17 15:59:28 2006 +0200
@@ -189,7 +189,7 @@ class PosixReactorBase(ReactorBase):
         if platformType == 'posix':
             signal.signal(signal.SIGCHLD, self._handleSigchld)
 
-    def _handleSigchld(self, signum, frame, _threadSupport=platform.supportsThreads()):
+    def _handleSigchld(self, signum, frame):
         """Reap all processes on SIGCHLD.
 
         This gets called on SIGCHLD. We do no processing inside a signal
@@ -198,10 +198,7 @@ class PosixReactorBase(ReactorBase):
         eventloop round prevents us from violating the state constraints
         of arbitrary classes.
         """
-        if _threadSupport:
-            self.callFromThread(process.reapAllProcesses)
-        else:
-            self.callLater(0, process.reapAllProcesses)
+        self.callLater(0, process.reapAllProcesses)
 
     def startRunning(self, installSignalHandlers=1):
         # Just in case we're started on a different thread than




More information about the Twisted-Python mailing list