From 8773f2f4260e78f5fd099f2e18a4ddd3bf841b9f 2013-09-04 19:34:25 From: MinRK Date: 2013-09-04 19:34:25 Subject: [PATCH] use forceful restart / shutdown in KM / MKM tests --- diff --git a/IPython/kernel/tests/test_kernelmanager.py b/IPython/kernel/tests/test_kernelmanager.py index ad6fef4..fdefe2d 100644 --- a/IPython/kernel/tests/test_kernelmanager.py +++ b/IPython/kernel/tests/test_kernelmanager.py @@ -26,18 +26,11 @@ class TestKernelManager(TestCase): def _run_lifecycle(self, km): km.start_kernel(stdout=PIPE, stderr=PIPE) self.assertTrue(km.is_alive()) - km.restart_kernel() + km.restart_kernel(now=True) self.assertTrue(km.is_alive()) - # We need a delay here to give the restarting kernel a chance to - # restart. Otherwise, the interrupt will kill it, causing the test - # suite to hang. The reason it *hangs* is that the shutdown - # message for the restart sometimes hasn't been sent to the kernel. - # Because linger is oo on the shell channel, the context can't - # close until the message is sent to the kernel, which is not dead. - time.sleep(1.0) km.interrupt_kernel() self.assertTrue(isinstance(km, KernelManager)) - km.shutdown_kernel() + km.shutdown_kernel(now=True) def test_tcp_lifecycle(self): km = self._get_tcp_km() diff --git a/IPython/kernel/tests/test_multikernelmanager.py b/IPython/kernel/tests/test_multikernelmanager.py index 0c6ffe5..1136af2 100644 --- a/IPython/kernel/tests/test_multikernelmanager.py +++ b/IPython/kernel/tests/test_multikernelmanager.py @@ -31,20 +31,13 @@ class TestKernelManager(TestCase): self.assertTrue(kid in km) self.assertTrue(kid in km.list_kernel_ids()) self.assertEqual(len(km),1) - km.restart_kernel(kid) + km.restart_kernel(kid, now=True) self.assertTrue(km.is_alive(kid)) self.assertTrue(kid in km.list_kernel_ids()) - # We need a delay here to give the restarting kernel a chance to - # restart. Otherwise, the interrupt will kill it, causing the test - # suite to hang. The reason it *hangs* is that the shutdown - # message for the restart sometimes hasn't been sent to the kernel. - # Because linger is oo on the shell channel, the context can't - # close until the message is sent to the kernel, which is not dead. - time.sleep(1.0) km.interrupt_kernel(kid) k = km.get_kernel(kid) self.assertTrue(isinstance(k, KernelManager)) - km.shutdown_kernel(kid) + km.shutdown_kernel(kid, now=True) self.assertTrue(not kid in km) def _run_cinfo(self, km, transport, ip): @@ -63,7 +56,7 @@ class TestKernelManager(TestCase): self.assertTrue('hb_port' in cinfo) stream = km.connect_hb(kid) stream.close() - km.shutdown_kernel(kid) + km.shutdown_kernel(kid, now=True) def test_tcp_lifecycle(self): km = self._get_tcp_km()