Commit 48d70025 authored by Denis Bilenko's avatar Denis Bilenko

fix syntax of xtest_signal.py on python2.6

parent 0edc17f4
...@@ -38,37 +38,38 @@ def test_main(): ...@@ -38,37 +38,38 @@ def test_main():
# re-raises information about any exceptions the child # re-raises information about any exceptions the child
# throws. The real work happens in self.run_test(). # throws. The real work happens in self.run_test().
os_done_r, os_done_w = os.pipe() os_done_r, os_done_w = os.pipe()
with closing(os.fdopen(os_done_r)) as done_r, closing(os.fdopen(os_done_w, 'w')) as done_w: with closing(os.fdopen(os_done_r)) as done_r:
child = gevent.fork() with closing(os.fdopen(os_done_w, 'w')) as done_w:
if not child: child = gevent.fork()
# In the child process; run the test and report results if not child:
# through the pipe. # In the child process; run the test and report results
try: # through the pipe.
done_r.close() try:
# Have to close done_w again here because done_r.close()
# exit_subprocess() will skip the enclosing with block. # Have to close done_w again here because
with closing(done_w): # exit_subprocess() will skip the enclosing with block.
try: with closing(done_w):
run_test() try:
except: run_test()
pickle.dump(traceback.format_exc(), done_w) except:
else: pickle.dump(traceback.format_exc(), done_w)
pickle.dump(None, done_w) else:
except: pickle.dump(None, done_w)
print('Uh oh, raised from pickle.') except:
traceback.print_exc() print('Uh oh, raised from pickle.')
finally: traceback.print_exc()
os._exit(0) finally:
os._exit(0)
done_w.close() done_w.close()
# Block for up to MAX_DURATION seconds for the test to finish. # Block for up to MAX_DURATION seconds for the test to finish.
r, w, x = select.select([done_r], [], [], MAX_DURATION) r, w, x = select.select([done_r], [], [], MAX_DURATION)
if done_r in r: if done_r in r:
tb = pickle.load(done_r) tb = pickle.load(done_r)
assert not tb, tb assert not tb, tb
else: else:
os.kill(child, 9) os.kill(child, 9)
assert False, 'Test deadlocked after %d seconds.' % MAX_DURATION assert False, 'Test deadlocked after %d seconds.' % MAX_DURATION
if __name__ == "__main__": if __name__ == "__main__":
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment