Skip to content

Commit

Permalink
Additional to the actual signal, send a message on the control port.
Browse files Browse the repository at this point in the history
  • Loading branch information
filmor committed Sep 21, 2017
1 parent 147f2a2 commit 5a43bf0
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion jupyter_client/manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -254,7 +254,7 @@ def start_kernel(self, **kw):
# If kernel_cmd has been set manually, don't refer to a kernel spec
# Environment variables from kernel spec are added to os.environ
env.update(self.kernel_spec.env or {})

# launch the kernel subprocess
self.log.debug("Starting kernel: %s", kernel_cmd)
self.kernel = self._launch_kernel(kernel_cmd, env=env,
Expand Down Expand Up @@ -414,6 +414,7 @@ def interrupt_kernel(self):
if sys.platform == 'win32':
from .win_interrupt import send_interrupt
send_interrupt(self.kernel.win32_interrupt_event)
self._send_signal_message(signal.SIGINT)
else:
self.signal_kernel(signal.SIGINT)
else:
Expand All @@ -436,9 +437,17 @@ def signal_kernel(self, signum):
except OSError:
pass
self.kernel.send_signal(signum)
self._send_signal_message(signum)
else:
raise RuntimeError("Cannot signal kernel. No kernel is running!")

def _send_signal_message(self, signum):
"""Send a signal request to the kernels control socket."""
content = dict(signum=signum)
msg = self.session.msg("signal_request", content=content)
self._connect_control_socket()
self.session.send(self._control_socket, msg)

def is_alive(self):
"""Is the kernel process still running?"""
if self.has_kernel:
Expand Down

0 comments on commit 5a43bf0

Please sign in to comment.