Skip to content

Commit 12da5fb

Browse files
committed
Changed kernel_id generation method name and calling scenario
Per review comments, the name of the method to generate a kernel_id was changed to `new_kernel_id()`. In addition, the method is now only called if `kernel_id` is not represented in the keyword arguments (`**kwargs`).
1 parent 238314d commit 12da5fb

File tree

1 file changed

+5
-6
lines changed

1 file changed

+5
-6
lines changed

jupyter_client/multikernelmanager.py

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -86,11 +86,11 @@ def start_kernel(self, kernel_name=None, **kwargs):
8686
"""Start a new kernel.
8787
8888
The caller can pick a kernel_id by passing one in as a keyword arg,
89-
otherwise one will be picked using a uuid.
89+
otherwise one will be generated using new_kernel_id().
9090
9191
The kernel ID for the newly started kernel is returned.
9292
"""
93-
kernel_id = self.determine_kernel_id(**kwargs)
93+
kernel_id = kwargs.pop('kernel_id', self.new_kernel_id(**kwargs))
9494
if kernel_id in self:
9595
raise DuplicateKernelError('Kernel already exists: %s' % kernel_id)
9696

@@ -316,12 +316,11 @@ def connect_hb(self, kernel_id, identity=None):
316316
stream : zmq Socket or ZMQStream
317317
"""
318318

319-
def determine_kernel_id(self, **kwargs):
319+
def new_kernel_id(self, **kwargs):
320320
"""
321-
Returns the kernel_id to use for this request. If kernel_id is already in the arguments list,
322-
that value will be used. Otherwise, a newly generated uuid is used. Subclasses may override
321+
Returns the id to associate with the kernel for this request. Subclasses may override
323322
this method to substitute other sources of kernel ids.
324323
:param kwargs:
325324
:return: string-ized version 4 uuid
326325
"""
327-
return kwargs.pop('kernel_id', unicode_type(uuid.uuid4()))
326+
return unicode_type(uuid.uuid4())

0 commit comments

Comments
 (0)