From d849fc610b785a7e274db82f85f92f922924e25e 2013-01-16 23:21:27 From: Brian Granger <ellisonbg@gmail.com> Date: 2013-01-16 23:21:27 Subject: [PATCH] Cleaning up MultiKernelManager test and adding linger=0 to shell. We are finding that the tests for MultiKernelManager hang because linger default to oo in the shell channel. By setting it to 0, the tests pass fine. Last night, we thought it was particular to the ipc transport, but now the hang occurs for any transport. --- diff --git a/IPython/frontend/html/notebook/tests/test_kernelsession.py b/IPython/frontend/html/notebook/tests/test_kernelsession.py index 3f216bb..f3ac9a5 100644 --- a/IPython/frontend/html/notebook/tests/test_kernelsession.py +++ b/IPython/frontend/html/notebook/tests/test_kernelsession.py @@ -31,37 +31,30 @@ class TestKernelManager(TestCase): km.shutdown_kernel(kid) self.assertTrue(not kid in km) - def test_km_tcp(self): - km = self._get_tcp_km() - self._run_lifecycle(km) - - def test_km_ipc(self): - km = self._get_ipc_km() - self._run_lifecycle(km) - - def test_tcp_cinfo(self): - km = self._get_tcp_km() + def _run_cinfo(self, km, transport, ip): kid = km.start_kernel() k = km.get_kernel(kid) cinfo = km.get_connection_info(kid) - self.assertEqual('tcp', cinfo['transport']) - self.assertEqual('127.0.0.1', cinfo['ip']) + self.assertEqual(transport, cinfo['transport']) + self.assertEqual(ip, cinfo['ip']) self.assertTrue('stdin_port' in cinfo) self.assertTrue('iopub_port' in cinfo) self.assertTrue('shell_port' in cinfo) self.assertTrue('hb_port' in cinfo) km.shutdown_kernel(kid) + def test_km_tcp(self): + km = self._get_tcp_km() + self._run_lifecycle(km) + + def test_tcp_cinfo(self): + km = self._get_tcp_km() + self._run_cinfo(km, 'tcp', '127.0.0.1') + + def test_km_ipc(self): + km = self._get_ipc_km() + self._run_lifecycle(km) + def test_ipc_cinfo(self): km = self._get_ipc_km() - kid = km.start_kernel() - k = km.get_kernel(kid) - cinfo = km.get_connection_info(kid) - self.assertEqual('ipc', cinfo['transport']) - self.assertEqual('test', cinfo['ip']) - self.assertTrue('stdin_port' in cinfo) - self.assertTrue('iopub_port' in cinfo) - self.assertTrue('shell_port' in cinfo) - self.assertTrue('hb_port' in cinfo) - km.shutdown_kernel(kid) - + self._run_cinfo(km, 'ipc', 'test') diff --git a/IPython/zmq/kernelmanager.py b/IPython/zmq/kernelmanager.py index 10a6ceb..6ab6e08 100644 --- a/IPython/zmq/kernelmanager.py +++ b/IPython/zmq/kernelmanager.py @@ -201,6 +201,7 @@ class ShellChannel(ZMQSocketChannel): """The thread's main activity. Call start() instead.""" self.socket = self.context.socket(zmq.DEALER) self.socket.setsockopt(zmq.IDENTITY, self.session.bsession) + self.socket.linger = 0 self.socket.connect(self.address) self.stream = zmqstream.ZMQStream(self.socket, self.ioloop) self.stream.on_recv(self._handle_recv)