Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

#6832 disabling magic kernels on ipython shutdown #6847

Merged
merged 2 commits into from
Feb 13, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 6 additions & 4 deletions beakerx/beakerx_magics/groovy_magic.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,17 @@
from IPython import get_ipython
from IPython.core.magic import (Magics, magics_class, cell_magic)
from jupyter_client.manager import KernelManager
import atexit


@magics_class
class GroovyMagics(Magics):
_execution_count = 1

def stop_kernel(self):
self.kc.stop_channels()
self.km.shutdown_kernel(now=True)

def __init__(self, shell):
super(GroovyMagics, self).__init__(shell)
self.km = None
Expand All @@ -29,6 +34,7 @@ def start(self):
self.km = KernelManager()
self.km.kernel_name = 'groovy'
self.km.start_kernel()
atexit.register(self.stop_kernel)
self.kc = self.km.client()
self.kc.start_channels()
try:
Expand All @@ -37,10 +43,6 @@ def start(self):
except AttributeError:
self._wait_for_ready_backport()

def __del__(self):
self.kc.stop_channels()
self.km.shutdown_kernel(now=True)

def run_cell(self, line, code):
if not self.km:
self.start()
Expand Down