From 55b9868fdbe2557dba06c1b54f8695f56ee58571 2014-05-12 22:41:04 From: Thomas Kluyver Date: 2014-05-12 22:41:04 Subject: [PATCH] Pass Windows interrupt event to kernels as an environment variable This allows third party kernels to use our interrupt mechanism on Windows. Closes gh-5840 --- diff --git a/IPython/kernel/launcher.py b/IPython/kernel/launcher.py index 379555f..dc95c04 100644 --- a/IPython/kernel/launcher.py +++ b/IPython/kernel/launcher.py @@ -174,6 +174,8 @@ def launch_kernel(cmd, stdin=None, stdout=None, stderr=None, env=None, else: _stdout, _stderr = stdout, stderr + env = env if (env is not None) else os.environ.copy() + encoding = getdefaultencoding(prefer_stream=False) # Spawn a kernel. @@ -186,6 +188,9 @@ def launch_kernel(cmd, stdin=None, stdout=None, stderr=None, env=None, from IPython.kernel.zmq.parentpoller import ParentPollerWindows # Create a Win32 event for interrupting the kernel. interrupt_event = ParentPollerWindows.create_interrupt_event() + # Store this in an environment variable for third party kernels, but at + # present, our own kernel expects this as a command line argument. + env["IPY_INTERRUPT_EVENT"] = str(interrupt_event) if ipython_kernel: cmd += [ '--interrupt=%i' % interrupt_event ]