]> granicus.if.org Git - python/commitdiff
Backport the Popen.poll() protection from subprocess to multiprocessing. See #1731717.
authorFlorent Xicluna <florent.xicluna@gmail.com>
Sun, 7 Mar 2010 23:49:03 +0000 (23:49 +0000)
committerFlorent Xicluna <florent.xicluna@gmail.com>
Sun, 7 Mar 2010 23:49:03 +0000 (23:49 +0000)
It should fix transient failures on test_multiprocessing.

Lib/multiprocessing/forking.py

index 7eda99180ac6ee93bd9b8ebaf9ac1149e32c8820..a66f7a0889ceff6fa2ad7299a8a8ea274c55c516 100644 (file)
@@ -103,7 +103,12 @@ if sys.platform != 'win32':
 
         def poll(self, flag=os.WNOHANG):
             if self.returncode is None:
-                pid, sts = os.waitpid(self.pid, flag)
+                try:
+                    pid, sts = os.waitpid(self.pid, flag)
+                except os.error:
+                    # Child process not yet created. See #1731717
+                    # e.errno == errno.ECHILD == 10
+                    return None
                 if pid == self.pid:
                     if os.WIFSIGNALED(sts):
                         self.returncode = -os.WTERMSIG(sts)