From b7a7c31422fb3ef2a857124aa3f4d153005b2609 Mon Sep 17 00:00:00 2001 From: Nathaniel Nicandro Date: Tue, 25 Jun 2019 09:33:08 -0500 Subject: [PATCH] Add `jupyter-kernel-managers` --- jupyter-client.el | 2 +- jupyter-kernel-manager.el | 16 +++++++++++++++- 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/jupyter-client.el b/jupyter-client.el index df5a0bd..89209e3 100644 --- a/jupyter-client.el +++ b/jupyter-client.el @@ -194,7 +194,7 @@ passed as the argument has a language of LANG." (jupyter-stop-channels client))))) (defun jupyter-clients () - "Return a list of all `jupyter-kernel-clients'." + "Return a list of all `jupyter-kernel-client' objects." (jupyter-all-objects 'jupyter--clients)) (defun jupyter-find-client-for-session (session-id) diff --git a/jupyter-kernel-manager.el b/jupyter-kernel-manager.el index 6868ece..eb66cf0 100644 --- a/jupyter-kernel-manager.el +++ b/jupyter-kernel-manager.el @@ -258,7 +258,17 @@ argument of the process." (unless (memq system-type '(ms-dos windows-nt cygwin)) (jupyter--block-until-conn-file-access atime kernel conn-file)))))) -(defclass jupyter-kernel-manager (jupyter-kernel-lifetime) +(defvar jupyter--kernel-managers nil) + +;; TODO: Move to generalize the kernel manager even more so it is independent +;; of a control channel and only relies mainly on the kernel and possibly some +;; other general object that can also be a control channel. This way we can +;; avoid this class. +(defclass jupyter-kernel-manager-base (jupyter-kernel-lifetime + jupyter-instance-tracker) + ((tracking-symbol :initform 'jupyter--kernel-managers))) + +(defclass jupyter-kernel-manager (jupyter-kernel-manager-base) ((kernel :type jupyter-meta-kernel :initarg :kernel @@ -268,6 +278,10 @@ argument of the process." :initform nil :documentation "The kernel's control channel."))) +(defun jupyter-kernel-managers () + "Return a list of all `jupyter-kernel-manager' objects." + (jupyter-all-objects 'jupyter--kernel-managers)) + (cl-defgeneric jupyter-make-client ((manager jupyter-kernel-manager) class &rest slots) "Make a new client from CLASS connected to MANAGER's kernel. SLOTS are the slots used to initialize the client with.")