From 18d090a99c9509092f1152d820d72e21ea6cb05a Mon Sep 17 00:00:00 2001 From: Quentin Peter Date: Sun, 4 Dec 2022 10:23:05 +0100 Subject: [PATCH] run server locally --- RELEASE.md | 1 + external-deps/qtconsole/qtconsole/comms.py | 2 +- external-deps/spyder-kernels-server/.gitignore | 3 +++ installers/Windows/req-extras-pull-request.txt | 1 + spyder/plugins/ipythonconsole/widgets/mixins.py | 16 ++++++++++++---- 5 files changed, 18 insertions(+), 5 deletions(-) create mode 100644 external-deps/spyder-kernels-server/.gitignore diff --git a/RELEASE.md b/RELEASE.md index dc9108d1251..01b89a9ef50 100644 --- a/RELEASE.md +++ b/RELEASE.md @@ -123,6 +123,7 @@ To release a new version of Spyder you need to follow these steps: * Update our subrepos with the following commands, but only if new versions are available! git subrepo pull external-deps/spyder-kernels + git subrepo pull external-deps/spyder-kernels-server git subrepo pull external-deps/python-lsp-server git subrepo pull external-deps/qtconsole diff --git a/external-deps/qtconsole/qtconsole/comms.py b/external-deps/qtconsole/qtconsole/comms.py index 74f8ce5c990..78cf5641cff 100644 --- a/external-deps/qtconsole/qtconsole/comms.py +++ b/external-deps/qtconsole/qtconsole/comms.py @@ -114,9 +114,9 @@ def get_comm(self, comm_id, closing=False): except KeyError: if closing: return - self.log.warning("No such comm: %s", comm_id) # don't create the list of keys if debug messages aren't enabled if self.log.isEnabledFor(logging.DEBUG): + self.log.debug("No such comm: %s", comm_id) self.log.debug("Current comms: %s", list(self.comms.keys())) # comm message handlers diff --git a/external-deps/spyder-kernels-server/.gitignore b/external-deps/spyder-kernels-server/.gitignore new file mode 100644 index 00000000000..570961b3a3a --- /dev/null +++ b/external-deps/spyder-kernels-server/.gitignore @@ -0,0 +1,3 @@ +.DS_Store +*.egg-info +__pycache__ diff --git a/installers/Windows/req-extras-pull-request.txt b/installers/Windows/req-extras-pull-request.txt index df35dfafbff..766417e3f29 100644 --- a/installers/Windows/req-extras-pull-request.txt +++ b/installers/Windows/req-extras-pull-request.txt @@ -24,4 +24,5 @@ spyder-terminal>=1.2.2 # Spyder external dependencies (spyder-kernels and qdarkstyle) ./external-deps/spyder-kernels +./external-deps/spyder-kernels-server ./external-deps/qdarkstyle diff --git a/spyder/plugins/ipythonconsole/widgets/mixins.py b/spyder/plugins/ipythonconsole/widgets/mixins.py index 792a42f51a4..c96adaebc85 100644 --- a/spyder/plugins/ipythonconsole/widgets/mixins.py +++ b/spyder/plugins/ipythonconsole/widgets/mixins.py @@ -8,6 +8,9 @@ IPython Console mixins. """ import zmq +import sys + +from qtpy.QtCore import QProcess # Local imports from spyder.plugins.ipythonconsole.utils.kernel_handler import KernelHandler @@ -17,11 +20,19 @@ class KernelConnectorMixin: """Needs https://github.com/jupyter/jupyter_client/pull/835""" def __init__(self): super().__init__() + self.hostname = None + self.sshkey = None + self.password = None + self.start_local_server() self.port = "5556" self.context = zmq.Context() self.socket = self.context.socket(zmq.REQ) self.socket.connect("tcp://localhost:%s" % self.port) + def start_local_server(self): + self.server = QProcess(self) + self.server.start(sys.executable, ["-m", "spyder_kernels_server"]) + def new_kernel(self, kernel_spec): """Get a new kernel""" self.socket.send_pyobj(["open_kernel", kernel_spec]) @@ -29,11 +40,9 @@ def new_kernel(self, kernel_spec): if connection_file == "error": raise connection_info - hostname, sshkey, password = None, None, None - kernel_handler = KernelHandler.new_from_spec( kernel_spec, connection_file, connection_info, - hostname, sshkey, password + self.hostname, self.sshkey, self.password ) kernel_handler.sig_request_close.connect(self.close_kernel) @@ -45,7 +54,6 @@ def close_kernel(self, connection_file): self.socket.recv_pyobj() - class CachedKernelMixin: """Cached kernel mixin.""" def __init__(self):