[Jython-checkins] jython: Fix Popen.__del__ failures that occur during GC.

jeff.allen jython-checkins at python.org
Sun Mar 2 21:24:48 CET 2014


http://hg.python.org/jython/rev/78efc2f8c832
changeset:   7191:78efc2f8c832
user:        Jeff Allen <ja.py at farowl.co.uk>
date:        Sun Mar 02 19:19:13 2014 +0000
summary:
  Fix Popen.__del__ failures that occur during GC.
Provides Jython version of subprocess.Popen._internal_poll method.

files:
  Lib/subprocess.py |  13 +++++++++++++
  1 files changed, 13 insertions(+), 0 deletions(-)


diff --git a/Lib/subprocess.py b/Lib/subprocess.py
--- a/Lib/subprocess.py
+++ b/Lib/subprocess.py
@@ -1353,6 +1353,19 @@
                     pass
             return self.returncode
 
+        def _internal_poll(self, _deadstate=None):
+            """Check if child process has terminated.  Returns returncode
+            attribute. Called by __del__."""
+            if self.returncode is None:
+                try:
+                    self.returncode = self._process.exitValue()
+                except java.lang.IllegalThreadStateException:
+                    # The child process is not ready to return status, so None os still right.
+                    pass
+                except java.io.IOException:
+                    # Child has exited but returncode lost?
+                    self.returncode = _deadstate
+            return self.returncode
 
         def wait(self):
             """Wait for child process to terminate.  Returns returncode

-- 
Repository URL: http://hg.python.org/jython


More information about the Jython-checkins mailing list