From 7a46b6bc6b3400ef70cd911898764c9899edb142 Mon Sep 17 00:00:00 2001 From: Min RK Date: Fri, 30 Nov 2018 13:21:58 +0100 Subject: [PATCH] set close_fds=False when starting kernels on Windows Python 3.7 sets close_fds=True by default, closing the interrupt/parent handles we are trying to pass to the kernel. --- jupyter_client/launcher.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/jupyter_client/launcher.py b/jupyter_client/launcher.py index 33f35a7c7..1ba206269 100644 --- a/jupyter_client/launcher.py +++ b/jupyter_client/launcher.py @@ -101,7 +101,8 @@ def launch_kernel(cmd, stdin=None, stdout=None, stderr=None, env=None, except: from _subprocess import DuplicateHandle, GetCurrentProcess, \ DUPLICATE_SAME_ACCESS, CREATE_NEW_PROCESS_GROUP - # Launch the kernel process + + # create a handle on the parent to be inherited if independent: kwargs['creationflags'] = CREATE_NEW_PROCESS_GROUP else: @@ -115,6 +116,11 @@ def launch_kernel(cmd, stdin=None, stdout=None, stderr=None, env=None, if redirect_out: kwargs['creationflags'] = kwargs.setdefault('creationflags', 0) | 0x08000000 # CREATE_NO_WINDOW + # Avoid closing the above parent and interrupt handles. + # close_fds is True by default on Python >=3.7 + # or when no stream is captured on Python <3.7 + # (we always capture stdin, so this is already False by default on <3.7) + kwargs['close_fds'] = False else: # Create a new session. # This makes it easier to interrupt the kernel,