Commit 4b4813d5 authored by Michal 'vorner' Vaner's avatar Michal 'vorner' Vaner
Browse files

[trac420] Make sure the subprocess doesn't outlive

It could happen in rare occasions that the subprocess survived death of
the tests, mostly when exceptions happened in the parent process and it
didn't kill it. So there's a finally now and the subprocess has a
limited life length just in case it still slipped somehow without kill.
parent ed69c4be
...@@ -189,9 +189,11 @@ class SendNonblock(unittest.TestCase): ...@@ -189,9 +189,11 @@ class SendNonblock(unittest.TestCase):
length = len(data) length = len(data)
queue_pid = os.fork() queue_pid = os.fork()
if queue_pid == 0: if queue_pid == 0:
msgq.register_socket(queue) msgq.register_socket(queue)
else: else:
def killall(signum, frame): def killall(signum, frame):
os.kill(queue_pid, signal.SIGTERM) os.kill(queue_pid, signal.SIGTERM)
sys.exit(1) sys.exit(1)
...@@ -201,10 +203,12 @@ class SendNonblock(unittest.TestCase): ...@@ -201,10 +203,12 @@ class SendNonblock(unittest.TestCase):
while time.clock() - now < 0.2: while time.clock() - now < 0.2:
out.sendall(msg) out.sendall(msg)
# Check the answer # Check the answer
(routing, received) = msgq.read_packet(out.fileno(), out) (routing, received) = msgq.read_packet(out.fileno(),
self.assertEqual({"type" : "pong"}, self.assertEqual({"type" : "pong"},
self.assertEqual(data, received) self.assertEqual(data, received)
os.kill(queue_pid, signal.SIGTERM) os.kill(queue_pid, signal.SIGTERM)
self.terminate_check(run) self.terminate_check(run)
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