Skip to content

Commit 0c1d882

Browse files
committed
issue #613: must await 'exit' and 'disconnect' in wait=False test
1 parent 6af337c commit 0c1d882

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

tests/router_test.py

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -434,12 +434,21 @@ def test_shutdown_wait_false(self):
434434
l1 = self.router.local()
435435
pid = l1.call(os.getpid)
436436

437-
conn = self.router.stream_by_id(l1.context_id).conn
437+
strm = self.router.stream_by_id(l1.context_id)
438438
exitted = mitogen.core.Latch()
439-
mitogen.core.listen(conn.proc, 'exit', exitted.put)
439+
440+
# It is possible for Process 'exit' signal to fire immediately during
441+
# processing of Stream 'disconnect' signal, so we must wait for both,
442+
# otherwise ChannelError below will return 'respondent context has
443+
# disconnected' rather than 'no route', because RouteMonitor hasn't run
444+
# yet and the Receiver caught Context 'disconnect' signal instead of a
445+
# dead message.
446+
mitogen.core.listen(strm.conn.proc, 'exit', exitted.put)
447+
mitogen.core.listen(strm, 'disconnect', exitted.put)
440448

441449
l1.shutdown(wait=False)
442450
exitted.get()
451+
exitted.get()
443452

444453
e = self.assertRaises(OSError,
445454
lambda: os.waitpid(pid, 0))

0 commit comments

Comments
 (0)