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,23 +189,27 @@ class SendNonblock(unittest.TestCase):
length = len(data)
queue_pid = os.fork()
if queue_pid == 0:
signal.alarm(10)
msgq.register_socket(queue)
msgq.run()
else:
def killall(signum, frame):
try:
def killall(signum, frame):
os.kill(queue_pid, signal.SIGTERM)
sys.exit(1)
signal.signal(signal.SIGALRM, killall)
msg = msgq.preparemsg({"type" : "ping"}, data)
now = time.clock()
while time.clock() - now < 0.2:
out.sendall(msg)
# Check the answer
(routing, received) = msgq.read_packet(out.fileno(),
out)
self.assertEqual({"type" : "pong"},
isc.cc.message.from_wire(routing))
self.assertEqual(data, received)
finally:
os.kill(queue_pid, signal.SIGTERM)
sys.exit(1)
signal.signal(signal.SIGALRM, killall)
msg = msgq.preparemsg({"type" : "ping"}, data)
now = time.clock()
while time.clock() - now < 0.2:
out.sendall(msg)
# Check the answer
(routing, received) = msgq.read_packet(out.fileno(), out)
self.assertEqual({"type" : "pong"},
isc.cc.message.from_wire(routing))
self.assertEqual(data, received)
os.kill(queue_pid, signal.SIGTERM)
self.terminate_check(run)
def test_small_sends(self):
......
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