Skip to content

Commit 717d522

Browse files
committed
Let KernelManager hold kernel_id
Kernel providers will want to use the same kernel_id used by the MappingKernelManager as a means of managing a kernel's lifecycle. This PR adds a `kernel_id` member to the KernelManager abstract base class and initializes its value in the KernelManager constructor. This allows kernel providers to determine the best location for where to set `kernel_id` so that it can be used to manage the kerne's lifecycle. The MappingKernelManager start logic will then derive the kernel_id from the provider's KernelManager instance. Fixes #10
1 parent 8a74331 commit 717d522

File tree

3 files changed

+6
-0
lines changed

3 files changed

+6
-0
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,3 +17,4 @@ __pycache__
1717
.cache
1818
.pytest_cache
1919
absolute.json
20+
.idea/

jupyter_kernel_mgmt/managerabc.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,9 @@
33
import six
44

55
class KernelManagerABC(six.with_metaclass(ABCMeta, object)):
6+
7+
kernel_id = None # Subclass should set kernel_id during initialization
8+
69
@abstractmethod
710
def is_alive(self):
811
"""Check whether the kernel is currently alive (e.g. the process exists)

jupyter_kernel_mgmt/subproc/manager.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
import subprocess
1313
import sys
1414
import time
15+
import uuid
1516

1617
log = logging.getLogger(__name__)
1718

@@ -39,6 +40,7 @@ def __init__(self, popen, files_to_cleanup=None, win_interrupt_evt=None):
3940
self.files_to_cleanup = files_to_cleanup or []
4041
self.win_interrupt_evt = win_interrupt_evt
4142
self.log = get_app_logger()
43+
self.kernel_id = str(uuid.uuid4())
4244

4345
def wait(self, timeout):
4446
""""""

0 commit comments

Comments
 (0)