Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
11 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -28,16 +28,16 @@ | |
|
||
|
||
class KernelSessionRecordConflict(Exception): | ||
"""An exception raised when""" | ||
|
||
pass | ||
|
||
|
||
@dataclass | ||
class KernelSessionRecord: | ||
"""A record object for tracking a Jupyter Server Kernel Session. | ||
Two records are equal if they share the | ||
Two records that share a session_id must also share a kernel_id, while | ||
kernels can have multiple session (and thereby) session_ids | ||
associated with them. | ||
""" | ||
|
||
session_id: Union[None, str] = None | ||
|
@@ -89,11 +89,12 @@ def update(self, other: "KernelSessionRecord") -> None: | |
|
||
|
||
class KernelSessionRecordList: | ||
"""Handy object for storing and managing a list of KernelSessionRecords. | ||
"""An object for storing and managing a list of KernelSessionRecords. | ||
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong.
Zsailer
Author
Member
|
||
When adding a record to the list, first checks if the record | ||
already exists. If it does, the record will be updated with | ||
the new information. | ||
When adding a record to the list, the KernelSessionRecordList | ||
first checks if the record already exists in the list. If it does, | ||
the record will be updated with the new information; otherwise, | ||
it will be appended. | ||
""" | ||
|
||
def __init__(self, *records): | ||
|
@@ -119,6 +120,9 @@ def __len__(self): | |
return len(self._records) | ||
|
||
def get(self, record: Union[KernelSessionRecord, str]) -> KernelSessionRecord: | ||
"""Return a full KernelSessionRecord from a session_id, kernel_id, or | ||
incomplete KernelSessionRecord. | ||
""" | ||
if isinstance(record, str): | ||
for r in self._records: | ||
if record == r.kernel_id or record == r.session_id: | ||
|
Not so handy it seems. 😄