##// END OF EJS Templates
add MultiKernelManager.default_kernel_name configurable...
MinRK -
Show More
@@ -1,20 +1,7 b''
1 """A kernel manager for multiple kernels
1 """A kernel manager for multiple kernels"""
2
2
3 Authors:
3 # Copyright (c) IPython Development Team.
4
4 # Distributed under the terms of the Modified BSD License.
5 * Brian Granger
6 """
7
8 #-----------------------------------------------------------------------------
9 # Copyright (C) 2013 The IPython Development Team
10 #
11 # Distributed under the terms of the BSD License. The full license is in
12 # the file COPYING, distributed as part of this software.
13 #-----------------------------------------------------------------------------
14
15 #-----------------------------------------------------------------------------
16 # Imports
17 #-----------------------------------------------------------------------------
18
5
19 from __future__ import absolute_import
6 from __future__ import absolute_import
20
7
@@ -30,15 +17,12 b' from IPython.utils.traitlets import ('
30 )
17 )
31 from IPython.utils.py3compat import unicode_type
18 from IPython.utils.py3compat import unicode_type
32
19
33 #-----------------------------------------------------------------------------
20 from .kernelspec import NATIVE_KERNEL_NAME
34 # Classes
35 #-----------------------------------------------------------------------------
36
21
37 class DuplicateKernelError(Exception):
22 class DuplicateKernelError(Exception):
38 pass
23 pass
39
24
40
25
41
42 def kernel_method(f):
26 def kernel_method(f):
43 """decorator for proxying MKM.method(kernel_id) to individual KMs by ID"""
27 """decorator for proxying MKM.method(kernel_id) to individual KMs by ID"""
44 def wrapped(self, kernel_id, *args, **kwargs):
28 def wrapped(self, kernel_id, *args, **kwargs):
@@ -58,6 +42,10 b' def kernel_method(f):'
58 class MultiKernelManager(LoggingConfigurable):
42 class MultiKernelManager(LoggingConfigurable):
59 """A class for managing multiple kernels."""
43 """A class for managing multiple kernels."""
60
44
45 default_kernel_name = Unicode(NATIVE_KERNEL_NAME, config=True,
46 help="The name of the default kernel to start"
47 )
48
61 kernel_manager_class = DottedObjectName(
49 kernel_manager_class = DottedObjectName(
62 "IPython.kernel.ioloop.IOLoopKernelManager", config=True,
50 "IPython.kernel.ioloop.IOLoopKernelManager", config=True,
63 help="""The kernel manager class. This is configurable to allow
51 help="""The kernel manager class. This is configurable to allow
@@ -92,7 +80,7 b' class MultiKernelManager(LoggingConfigurable):'
92 def __contains__(self, kernel_id):
80 def __contains__(self, kernel_id):
93 return kernel_id in self._kernels
81 return kernel_id in self._kernels
94
82
95 def start_kernel(self, kernel_name='python', **kwargs):
83 def start_kernel(self, kernel_name=None, **kwargs):
96 """Start a new kernel.
84 """Start a new kernel.
97
85
98 The caller can pick a kernel_id by passing one in as a keyword arg,
86 The caller can pick a kernel_id by passing one in as a keyword arg,
@@ -106,6 +94,9 b' class MultiKernelManager(LoggingConfigurable):'
106 kernel_id = kwargs.pop('kernel_id', unicode_type(uuid.uuid4()))
94 kernel_id = kwargs.pop('kernel_id', unicode_type(uuid.uuid4()))
107 if kernel_id in self:
95 if kernel_id in self:
108 raise DuplicateKernelError('Kernel already exists: %s' % kernel_id)
96 raise DuplicateKernelError('Kernel already exists: %s' % kernel_id)
97
98 if kernel_name is None:
99 kernel_name = self.default_kernel_name
109 # kernel_manager_factory is the constructor for the KernelManager
100 # kernel_manager_factory is the constructor for the KernelManager
110 # subclass we are using. It can be configured as any Configurable,
101 # subclass we are using. It can be configured as any Configurable,
111 # including things like its transport and ip.
102 # including things like its transport and ip.
General Comments 0
You need to be logged in to leave comments. Login now