[Pytest-commit] commit/py: hpk42: Merged in schlamar/py/schlamar/dont-skip-exit-handlers-in-forkedfunc-t-1401701628841 (pull request #14)
commits-noreply at bitbucket.org
commits-noreply at bitbucket.org
Mon Jun 2 11:37:27 CEST 2014
1 new commit in py:
https://bitbucket.org/hpk42/py/commits/5d8aaac89ffc/
Changeset: 5d8aaac89ffc
User: hpk42
Date: 2014-06-02 11:36:55
Summary: Merged in schlamar/py/schlamar/dont-skip-exit-handlers-in-forkedfunc-t-1401701628841 (pull request #14)
Don't skip exit handlers in ForkedFunc.
Affected #: 1 file
diff -r f7c2b8011d273c2f69872b662c6b5765356827a5 -r 5d8aaac89ffc8d5077e612b8d067332c18753b2c py/_process/forkedfunc.py
--- a/py/_process/forkedfunc.py
+++ b/py/_process/forkedfunc.py
@@ -3,8 +3,6 @@
ForkedFunc provides a way to run a function in a forked process
and get at its return value, stdout and stderr output as well
as signals and exitstatusus.
-
- XXX see if tempdir handling is sane
"""
import py
@@ -12,8 +10,10 @@
import sys
import marshal
+
class ForkedFunc(object):
EXITSTATUS_EXCEPTION = 3
+
def __init__(self, fun, args=None, kwargs=None, nice_level=0):
if args is None:
args = []
@@ -28,9 +28,10 @@
self.STDERR = tempdir.ensure('stderr')
pid = os.fork()
- if pid: # in parent process
+ if pid: # in parent process
self.pid = pid
- else: # in child process
+ else: # in child process
+ self.pid = None
self._child(nice_level)
def _child(self, nice_level):
@@ -62,7 +63,7 @@
retvalf.close()
os.close(1)
os.close(2)
- os._exit(EXITSTATUS)
+ sys.exit(EXITSTATUS)
def waitfinish(self, waiter=os.waitpid):
pid, systemstatus = waiter(self.pid, 0)
@@ -71,8 +72,6 @@
exitstatus = os.WTERMSIG(systemstatus) + 128
else:
exitstatus = os.WEXITSTATUS(systemstatus)
- #raise ExecutionFailed(status, systemstatus, cmd,
- # ''.join(out), ''.join(err))
else:
exitstatus = 0
signal = systemstatus & 0x7f
@@ -95,7 +94,9 @@
self.tempdir.remove()
def __del__(self):
- self._removetemp()
+ if self.pid is not None: # only clean up in main process
+ self._removetemp()
+
class Result(object):
def __init__(self, exitstatus, signal, retval, stdout, stderr):
Repository URL: https://bitbucket.org/hpk42/py/
--
This is a commit notification from bitbucket.org. You are receiving
this because you have the service enabled, addressing the recipient of
this email.
More information about the pytest-commit
mailing list