Skip to content

Commit

Permalink
Avoid zombie shells - addresses #30
Browse files Browse the repository at this point in the history
  • Loading branch information
blink1073 committed Sep 7, 2014
1 parent 753c936 commit 1b1058d
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
2 changes: 1 addition & 1 deletion jupyter_kernel/magics/help_magic.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ def get_help_on(self, info, level):
if info['magic']:

if info['magic']['name'] == 'help':
return self.get_help('line', 'help')
return self.get_help('line', 'help', level)

minfo = info['magic']
errmsg = "No such %s magic '%s'" % (minfo['type'], minfo['name'])
Expand Down
7 changes: 6 additions & 1 deletion jupyter_kernel/magics/shell_magic.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
from jupyter_kernel import Magic
import subprocess
import os
import signal
import atexit
import threading
import time
try:
Expand Down Expand Up @@ -86,6 +86,8 @@ def start_process(self):

self.proc = subprocess.Popen(self.cmd, **kwargs)

atexit.register(self.proc.terminate)

self._error_thread = threading.Thread(target=self._read_errors)
self._error_queue = Queue.Queue()
self._error_thread.setDaemon(True)
Expand Down Expand Up @@ -116,6 +118,9 @@ def get_help_on(self, info, level=0):
else:
return "Sorry, no help is available on '%s'." % expr

def __del__(self):
self.proc.terminate()


def register_magics(kernel):
kernel.register_magics(ShellMagic)

0 comments on commit 1b1058d

Please sign in to comment.