From de149b2f5de47100ccf3b90b7a265250e8306f7b Mon Sep 17 00:00:00 2001 From: Thomas Grainger Date: Sun, 28 Jun 2015 22:45:08 +0100 Subject: [PATCH] support ChildWatcher.rstatus --- known_failures.patch | 11 +---------- tulipcore.py | 11 +++++++++-- 2 files changed, 10 insertions(+), 12 deletions(-) diff --git a/known_failures.patch b/known_failures.patch index 1aaf540..0b5dd0c 100644 --- a/known_failures.patch +++ b/known_failures.patch @@ -1,28 +1,19 @@ --- known_failures.py 2015-06-28 14:33:12.270911380 +0100 +++ known_failures.py 2015-06-28 14:33:04.303661343 +0100 -@@ -107,6 +107,26 @@ +@@ -107,6 +107,16 @@ FLAKY test__socket.py '''.strip().split() +FAILING_TESTS += ''' -+ test__subprocess_poll.py + test_close_backend_fd.py + test_hub_join_timeout.py -+ test__example_udp_client.py + test_hub_join.py + test__subprocess.py -+ test_threading_2.py + test__destroy.py + test__server.py -+ test__doctests.py + test__core_stat.py -+ test__example_portforwarder.py -+ test__example_udp_server.py + test__environ.py +'''.strip().split() -+ -+if os.environ.get('GEVENT_FILE') == 'thread' or os.environ.get('GEVENT_RESOLVER') == 'thread': -+ FAILING_TESTS += 'FLAKY test__examples.py' + if __name__ == '__main__': diff --git a/tulipcore.py b/tulipcore.py index d779c5d..dffbd18 100644 --- a/tulipcore.py +++ b/tulipcore.py @@ -179,7 +179,7 @@ def __init__(self, loop, pid, ref=True): super().__init__(loop, ref=ref) self.pid = pid self.watcher = self.loop.policy.get_child_watcher() - self.rcode = None + self.rstatus = None self.rpid = None def _start(self): @@ -190,8 +190,15 @@ def _stop(self): self.watcher.remove_child_handler(self.pid) def _invoke_wrapper(self, pid, retcode): + # asyncio messes with the status code value, go up the stack and get it + try: + outer_frame = sys._getframe(1) + status = outer_frame.f_locals['status'] + finally: + del outer_frame + self.rpid = pid - self.rcode = retcode + self.rstatus = status self._invoke()