Show More
@@ -1,5 +1,6 b'' | |||||
1 | """Tests for the notebook kernel and session manager.""" |
|
1 | """Tests for the notebook kernel and session manager.""" | |
2 |
|
2 | |||
|
3 | import time | |||
3 | from unittest import TestCase |
|
4 | from unittest import TestCase | |
4 |
|
5 | |||
5 | from IPython.config.loader import Config |
|
6 | from IPython.config.loader import Config | |
@@ -25,6 +26,13 b' class TestKernelManager(TestCase):' | |||||
25 | self.assertEqual(len(km),1) |
|
26 | self.assertEqual(len(km),1) | |
26 | km.restart_kernel(kid) |
|
27 | km.restart_kernel(kid) | |
27 | self.assertTrue(kid in km.list_kernel_ids()) |
|
28 | self.assertTrue(kid in km.list_kernel_ids()) | |
|
29 | # We need a delay here to give the restarting kernel a chance to | |||
|
30 | # restart. Otherwise, the interrupt will kill it, causing the test | |||
|
31 | # suite to hang. The reason it *hangs* is that the shutdown | |||
|
32 | # message for the restart sometimes hasn't been sent to the kernel. | |||
|
33 | # Because linger is oo on the shell channel, the context can't | |||
|
34 | # close until the message is sent to the kernel, which is not dead. | |||
|
35 | time.sleep(1.0) | |||
28 | km.interrupt_kernel(kid) |
|
36 | km.interrupt_kernel(kid) | |
29 | k = km.get_kernel(kid) |
|
37 | k = km.get_kernel(kid) | |
30 | self.assertTrue(isinstance(k, KernelManager)) |
|
38 | self.assertTrue(isinstance(k, KernelManager)) | |
@@ -43,7 +51,7 b' class TestKernelManager(TestCase):' | |||||
43 | self.assertTrue('hb_port' in cinfo) |
|
51 | self.assertTrue('hb_port' in cinfo) | |
44 | km.shutdown_kernel(kid) |
|
52 | km.shutdown_kernel(kid) | |
45 |
|
53 | |||
46 |
def test_ |
|
54 | def test_tcp_lifecycle(self): | |
47 | km = self._get_tcp_km() |
|
55 | km = self._get_tcp_km() | |
48 | self._run_lifecycle(km) |
|
56 | self._run_lifecycle(km) | |
49 |
|
57 | |||
@@ -51,10 +59,11 b' class TestKernelManager(TestCase):' | |||||
51 | km = self._get_tcp_km() |
|
59 | km = self._get_tcp_km() | |
52 | self._run_cinfo(km, 'tcp', '127.0.0.1') |
|
60 | self._run_cinfo(km, 'tcp', '127.0.0.1') | |
53 |
|
61 | |||
54 |
def test_ |
|
62 | def test_ipc_lifecycle(self): | |
55 | km = self._get_ipc_km() |
|
63 | km = self._get_ipc_km() | |
56 | self._run_lifecycle(km) |
|
64 | self._run_lifecycle(km) | |
57 |
|
65 | |||
58 | def test_ipc_cinfo(self): |
|
66 | def test_ipc_cinfo(self): | |
59 | km = self._get_ipc_km() |
|
67 | km = self._get_ipc_km() | |
60 | self._run_cinfo(km, 'ipc', 'test') |
|
68 | self._run_cinfo(km, 'ipc', 'test') | |
|
69 |
@@ -201,7 +201,6 b' class ShellChannel(ZMQSocketChannel):' | |||||
201 | """The thread's main activity. Call start() instead.""" |
|
201 | """The thread's main activity. Call start() instead.""" | |
202 | self.socket = self.context.socket(zmq.DEALER) |
|
202 | self.socket = self.context.socket(zmq.DEALER) | |
203 | self.socket.setsockopt(zmq.IDENTITY, self.session.bsession) |
|
203 | self.socket.setsockopt(zmq.IDENTITY, self.session.bsession) | |
204 | self.socket.linger = 0 |
|
|||
205 | self.socket.connect(self.address) |
|
204 | self.socket.connect(self.address) | |
206 | self.stream = zmqstream.ZMQStream(self.socket, self.ioloop) |
|
205 | self.stream = zmqstream.ZMQStream(self.socket, self.ioloop) | |
207 | self.stream.on_recv(self._handle_recv) |
|
206 | self.stream.on_recv(self._handle_recv) |
@@ -1,5 +1,6 b'' | |||||
1 | """Tests for the notebook kernel and session manager.""" |
|
1 | """Tests for the notebook kernel and session manager.""" | |
2 |
|
2 | |||
|
3 | import time | |||
3 | from unittest import TestCase |
|
4 | from unittest import TestCase | |
4 |
|
5 | |||
5 | from IPython.config.loader import Config |
|
6 | from IPython.config.loader import Config | |
@@ -20,17 +21,24 b' class TestKernelManager(TestCase):' | |||||
20 | def _run_lifecycle(self, km): |
|
21 | def _run_lifecycle(self, km): | |
21 | km.start_kernel() |
|
22 | km.start_kernel() | |
22 | km.start_channels(shell=True, iopub=False, stdin=False, hb=False) |
|
23 | km.start_channels(shell=True, iopub=False, stdin=False, hb=False) | |
23 | # km.shell_channel.start() |
|
|||
24 | km.restart_kernel() |
|
24 | km.restart_kernel() | |
|
25 | # We need a delay here to give the restarting kernel a chance to | |||
|
26 | # restart. Otherwise, the interrupt will kill it, causing the test | |||
|
27 | # suite to hang. The reason it *hangs* is that the shutdown | |||
|
28 | # message for the restart sometimes hasn't been sent to the kernel. | |||
|
29 | # Because linger is oo on the shell channel, the context can't | |||
|
30 | # close until the message is sent to the kernel, which is not dead. | |||
|
31 | time.sleep() | |||
25 | km.interrupt_kernel() |
|
32 | km.interrupt_kernel() | |
26 | self.assertTrue(isinstance(km, KernelManager)) |
|
33 | self.assertTrue(isinstance(km, KernelManager)) | |
27 | km.shutdown_kernel() |
|
34 | km.shutdown_kernel() | |
28 | km.shell_channel.stop() |
|
35 | km.shell_channel.stop() | |
29 |
|
36 | |||
30 |
def test_ |
|
37 | def test_tcp_lifecycle(self): | |
31 | km = self._get_tcp_km() |
|
38 | km = self._get_tcp_km() | |
32 | self._run_lifecycle(km) |
|
39 | self._run_lifecycle(km) | |
33 |
|
40 | |||
34 |
def test |
|
41 | def testipc_lifecycle(self): | |
35 | km = self._get_ipc_km() |
|
42 | km = self._get_ipc_km() | |
36 | self._run_lifecycle(km) |
|
43 | self._run_lifecycle(km) | |
|
44 |
General Comments 0
You need to be logged in to leave comments.
Login now