##// END OF EJS Templates
make MultiKernelManager.kernel_manager_class configurable...
MinRK -
Show More
@@ -27,10 +27,10 from zmq.eventloop.zmqstream import ZMQStream
27 from tornado import web
27 from tornado import web
28
28
29 from IPython.config.configurable import LoggingConfigurable
29 from IPython.config.configurable import LoggingConfigurable
30 from IPython.zmq.ipkernel import launch_kernel
30 from IPython.utils.importstring import import_item
31 from IPython.zmq.kernelmanager import KernelManager
31 from IPython.utils.traitlets import (
32 from IPython.utils.traitlets import Instance, Dict, List, Unicode, Float, Integer
32 Instance, Dict, List, Unicode, Float, Integer, Any, DottedObjectName,
33
33 )
34 #-----------------------------------------------------------------------------
34 #-----------------------------------------------------------------------------
35 # Classes
35 # Classes
36 #-----------------------------------------------------------------------------
36 #-----------------------------------------------------------------------------
@@ -41,7 +41,20 class DuplicateKernelError(Exception):
41
41
42 class MultiKernelManager(LoggingConfigurable):
42 class MultiKernelManager(LoggingConfigurable):
43 """A class for managing multiple kernels."""
43 """A class for managing multiple kernels."""
44
44
45 kernel_manager_class = DottedObjectName(
46 "IPython.zmq.kernelmanager.KernelManager", config=True,
47 help="""The kernel manager class. This is configurable to allow
48 subclassing of the KernelManager for customized behavior.
49 """
50 )
51 def _kernel_manager_class_changed(self, name, old, new):
52 self.kernel_manager_factory = import_item(new)
53
54 kernel_manager_factory = Any(help="this is kernel_manager_class after import")
55 def _kernel_manager_factory_default(self):
56 return import_item(self.kernel_manager_class)
57
45 context = Instance('zmq.Context')
58 context = Instance('zmq.Context')
46 def _context_default(self):
59 def _context_default(self):
47 return zmq.Context.instance()
60 return zmq.Context.instance()
@@ -69,7 +82,7 class MultiKernelManager(LoggingConfigurable):
69 """Start a new kernel."""
82 """Start a new kernel."""
70 kernel_id = unicode(uuid.uuid4())
83 kernel_id = unicode(uuid.uuid4())
71 # use base KernelManager for each Kernel
84 # use base KernelManager for each Kernel
72 km = KernelManager(connection_file=os.path.join(
85 km = self.kernel_manager_factory(connection_file=os.path.join(
73 self.connection_dir, "kernel-%s.json" % kernel_id),
86 self.connection_dir, "kernel-%s.json" % kernel_id),
74 config=self.config,
87 config=self.config,
75 )
88 )
@@ -194,7 +207,6 class MappingKernelManager(MultiKernelManager):
194 """A KernelManager that handles notebok mapping and HTTP error handling"""
207 """A KernelManager that handles notebok mapping and HTTP error handling"""
195
208
196 kernel_argv = List(Unicode)
209 kernel_argv = List(Unicode)
197 kernel_manager = Instance(KernelManager)
198
210
199 time_to_dead = Float(3.0, config=True, help="""Kernel heartbeat interval in seconds.""")
211 time_to_dead = Float(3.0, config=True, help="""Kernel heartbeat interval in seconds.""")
200 first_beat = Float(5.0, config=True, help="Delay (in seconds) before sending first heartbeat.")
212 first_beat = Float(5.0, config=True, help="Delay (in seconds) before sending first heartbeat.")
General Comments 0
You need to be logged in to leave comments. Login now