From 4bbb51033952c064b405d33c8efadbf12a31bbdd 2013-01-17 05:12:09 From: Brian E. Granger Date: 2013-01-17 05:12:09 Subject: [PATCH] Fixing last few things with the test suite for kernel managers. --- diff --git a/IPython/frontend/html/notebook/kernelmanager.py b/IPython/frontend/html/notebook/kernelmanager.py index c79ab6f..70d2f4f 100644 --- a/IPython/frontend/html/notebook/kernelmanager.py +++ b/IPython/frontend/html/notebook/kernelmanager.py @@ -79,6 +79,11 @@ class MultiKernelManager(LoggingConfigurable): The caller can pick a kernel_id by passing one in as a keyword arg, otherwise one will be picked using a uuid. + + To silence the kernel's stdout/stderr, call this using:: + + km.start_kernel(stdout=PIPE, stderr=PIPE) + """ kernel_id = kwargs.pop('kernel_id', unicode(uuid.uuid4())) if kernel_id in self: diff --git a/IPython/frontend/html/notebook/tests/test_kernelmanager.py b/IPython/frontend/html/notebook/tests/test_kernelmanager.py index 870f1a9..3b8c18a 100644 --- a/IPython/frontend/html/notebook/tests/test_kernelmanager.py +++ b/IPython/frontend/html/notebook/tests/test_kernelmanager.py @@ -1,5 +1,6 @@ """Tests for the notebook kernel and session manager.""" +from subprocess import PIPE import time from unittest import TestCase @@ -20,7 +21,7 @@ class TestKernelManager(TestCase): return km def _run_lifecycle(self, km): - kid = km.start_kernel() + kid = km.start_kernel(stdout=PIPE, stderr=PIPE) self.assertTrue(kid in km) self.assertTrue(kid in km.list_kernel_ids()) self.assertEqual(len(km),1) @@ -40,7 +41,7 @@ class TestKernelManager(TestCase): self.assertTrue(not kid in km) def _run_cinfo(self, km, transport, ip): - kid = km.start_kernel() + kid = km.start_kernel(stdout=PIPE, stderr=PIPE) k = km.get_kernel(kid) cinfo = km.get_connection_info(kid) self.assertEqual(transport, cinfo['transport']) diff --git a/IPython/zmq/tests/test_kernelmanager.py b/IPython/zmq/tests/test_kernelmanager.py index 05313a6..f6482c2 100644 --- a/IPython/zmq/tests/test_kernelmanager.py +++ b/IPython/zmq/tests/test_kernelmanager.py @@ -1,5 +1,6 @@ """Tests for the notebook kernel and session manager.""" +from subprocess import PIPE import time from unittest import TestCase @@ -19,7 +20,7 @@ class TestKernelManager(TestCase): return km def _run_lifecycle(self, km): - km.start_kernel() + km.start_kernel(stdout=PIPE, stderr=PIPE) km.start_channels(shell=True, iopub=False, stdin=False, hb=False) km.restart_kernel() # We need a delay here to give the restarting kernel a chance to @@ -28,7 +29,7 @@ class TestKernelManager(TestCase): # 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() + time.sleep(1.0) km.interrupt_kernel() self.assertTrue(isinstance(km, KernelManager)) km.shutdown_kernel()