Also raise exception on child process, to get a traceback for debugging

I initially thought I could pass the traceback with the exception, but
it seems transmitting exceptions around with their tracebacks intact is
not so easy. There's a library which does this:

https://github.com/ionelmc/python-tblib

But this doesn't seem important enough to introduce a dependency..
This commit is contained in:
Ellwood Zwovic
2017-07-09 15:10:00 -07:00
parent a4a1f69cd1
commit 24b1a19409

View File

@@ -70,7 +70,7 @@ def subprocess_operator(cls: Operator, polling_interval=.01) -> Operator:
try:
if self.pipe[0].poll():
resp = self.pipe[0].recv()
assert(isinstance(resp, SubprocessMessage))
# assert(isinstance(resp, SubprocessMessage))
else:
resp = None
except EOFError:
@@ -105,6 +105,7 @@ def subprocess_function(func, *args, pipe, **kwargs):
except Exception as err:
log.debug("Caught exception from subprocess: %s", err)
pipe[1].send(SubprocessMessage(exception=err))
raise
finally:
pipe[1].close()