[sldev-commits] r165 - trunk/eventlet

which.linden at svn.secondlife.com which.linden at svn.secondlife.com
Wed Apr 8 14:30:14 PDT 2009


Author: which.linden
Date: 2009-04-08 16:30:14 -0500 (Wed, 08 Apr 2009)
New Revision: 165

Modified:
   trunk/eventlet/processes.py
Trac: http://svn.secondlife.com/trac/eventlet/changeset/165
Log:
Worked around weird popen2/4 behavior in 2.4 by calling the popen2 wait rather than os.wait.  Per this discussion: https://lists.secondlife.com/pipermail/eventletdev/2009-March/000300.html . Reviewed by Kartic.

Modified: trunk/eventlet/processes.py
===================================================================
--- trunk/eventlet/processes.py	2009-02-28 00:27:17 UTC (rev 164)
+++ trunk/eventlet/processes.py	2009-04-08 21:30:14 UTC (rev 165)
@@ -33,7 +33,7 @@
 class DeadProcess(RuntimeError):
     pass
 
-def cooperative_wait(pid, check_interval=0.01):
+def cooperative_wait(pobj, check_interval=0.01):
     """ Waits for a child process to exit, returning the status
     code.
 
@@ -45,11 +45,10 @@
     that cooperative_wait will sleep between calls to os.waitpid.
     """
     try:
-        done = False
-        while not done:
-            # waitpid returns (0, 0) if the process is still
-            # alive, and (>0, >0) if it just exited
-            done, status = os.waitpid(pid, os.WNOHANG)
+        while True:
+            status = pobj.poll()
+            if status >= 0:
+                return status
             api.sleep(check_interval)
         return status
     except OSError, e:
@@ -93,7 +92,7 @@
         self.readline = self.child_stdout_stderr.readline
 
     def wait(self):
-        return cooperative_wait(self.getpid())
+        return cooperative_wait(self.popen4)
 
     def dead_callback(self):
         self.wait()



More information about the sldev-commits mailing list