From 1784f3c83acf7c7fec26b08e1d849fb7c86980e7 Mon Sep 17 00:00:00 2001 From: David Wilson Date: Tue, 3 Oct 2017 16:08:38 +0530 Subject: [PATCH] Add test that hangs the main thread during shutdown. --- tests/call_function_test.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/tests/call_function_test.py b/tests/call_function_test.py index 3dec3dc2..131e4079 100644 --- a/tests/call_function_test.py +++ b/tests/call_function_test.py @@ -1,4 +1,5 @@ import logging +import time import unittest import mitogen.core @@ -71,7 +72,13 @@ class CallFunctionTest(testlib.RouterMixin, testlib.TestCase): self.assertEquals(exc[0], mitogen.core.ChannelError.local_msg) def test_aborted_on_local_broker_shutdown(self): - assert 0, 'todo' + stream = self.router._stream_by_id[self.local.context_id] + recv = self.local.call_async(time.sleep, 120) + time.sleep(0.1) # Ensure GIL is released + self.broker.shutdown() + exc = self.assertRaises(mitogen.core.ChannelError, + lambda: recv.get()) + self.assertEquals(exc[0], mitogen.core.ChannelError.local_msg) def test_accepts_returns_context(self): context = self.local.call(func_accepts_returns_context, self.local)