Skip to content

Commit

Permalink
Merge pull request #1544 from minrk/multilingual
Browse files Browse the repository at this point in the history
make MultiKernelManager.kernel_manager_class configurable
  • Loading branch information
minrk committed Apr 3, 2012
2 parents aff7498 + e1e0bd0 commit a3791e4
Showing 1 changed file with 19 additions and 7 deletions.
26 changes: 19 additions & 7 deletions IPython/frontend/html/notebook/kernelmanager.py
Expand Up @@ -27,10 +27,10 @@
from tornado import web

from IPython.config.configurable import LoggingConfigurable
from IPython.zmq.ipkernel import launch_kernel
from IPython.zmq.kernelmanager import KernelManager
from IPython.utils.traitlets import Instance, Dict, List, Unicode, Float, Integer

from IPython.utils.importstring import import_item
from IPython.utils.traitlets import (
Instance, Dict, List, Unicode, Float, Integer, Any, DottedObjectName,
)
#-----------------------------------------------------------------------------
# Classes
#-----------------------------------------------------------------------------
Expand All @@ -41,7 +41,20 @@ class DuplicateKernelError(Exception):

class MultiKernelManager(LoggingConfigurable):
"""A class for managing multiple kernels."""


kernel_manager_class = DottedObjectName(
"IPython.zmq.kernelmanager.KernelManager", config=True,
help="""The kernel manager class. This is configurable to allow
subclassing of the KernelManager for customized behavior.
"""
)
def _kernel_manager_class_changed(self, name, old, new):
self.kernel_manager_factory = import_item(new)

kernel_manager_factory = Any(help="this is kernel_manager_class after import")
def _kernel_manager_factory_default(self):
return import_item(self.kernel_manager_class)

context = Instance('zmq.Context')
def _context_default(self):
return zmq.Context.instance()
Expand Down Expand Up @@ -69,7 +82,7 @@ def start_kernel(self, **kwargs):
"""Start a new kernel."""
kernel_id = unicode(uuid.uuid4())
# use base KernelManager for each Kernel
km = KernelManager(connection_file=os.path.join(
km = self.kernel_manager_factory(connection_file=os.path.join(
self.connection_dir, "kernel-%s.json" % kernel_id),
config=self.config,
)
Expand Down Expand Up @@ -194,7 +207,6 @@ class MappingKernelManager(MultiKernelManager):
"""A KernelManager that handles notebok mapping and HTTP error handling"""

kernel_argv = List(Unicode)
kernel_manager = Instance(KernelManager)

time_to_dead = Float(3.0, config=True, help="""Kernel heartbeat interval in seconds.""")
first_beat = Float(5.0, config=True, help="Delay (in seconds) before sending first heartbeat.")
Expand Down

0 comments on commit a3791e4

Please sign in to comment.