From 22092fa65ee0fd007bf59bfc7998b7d57743f0d2 Mon Sep 17 00:00:00 2001 From: Min RK Date: Fri, 15 Dec 2017 14:21:41 +0100 Subject: [PATCH] kill process group when killing kernel if killpg is available this should cleanup process trees (e.g. multiprocessing subprocesses) and make EADDRINUSE less likely during restart. --- jupyter_client/manager.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/jupyter_client/manager.py b/jupyter_client/manager.py index 52bf8b781..f488d5c42 100644 --- a/jupyter_client/manager.py +++ b/jupyter_client/manager.py @@ -372,7 +372,10 @@ def _kill_kernel(self): # Signal the kernel to terminate (sends SIGKILL on Unix and calls # TerminateProcess() on Win32). try: - self.kernel.kill() + if hasattr(signal, 'SIGKILL'): + self.signal_kernel(signal.SIGKILL) + else: + self.kernel.kill() except OSError as e: # In Windows, we will get an Access Denied error if the process # has already terminated. Ignore it.