From c5919d13477499e2a50d67f8385d2962c05e9782 Mon Sep 17 00:00:00 2001 From: Steven Silvester Date: Wed, 21 Sep 2022 10:31:04 -0500 Subject: [PATCH 1/3] client 8 support --- .github/workflows/ci.yml | 1 + ipykernel/inprocess/client.py | 12 ++++++++++-- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 8464830c8..aeeb5611e 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -198,6 +198,7 @@ jobs: pip check - name: Run the tests run: | + pip install jupyter_client@https://github.com/blink1073/jupyter_client/archive/refs/heads/synchronous_managers.zip cmd="python -m pytest -vv" $cmd || $cmd --lf diff --git a/ipykernel/inprocess/client.py b/ipykernel/inprocess/client.py index 807cad760..04627950a 100644 --- a/ipykernel/inprocess/client.py +++ b/ipykernel/inprocess/client.py @@ -15,6 +15,10 @@ from jupyter_client.client import KernelClient from jupyter_client.clientabc import KernelClientABC +try: + from jupyter_client.utils import run_sync # requires 7.0+ +except ImportError: + run_sync = None # IPython imports from traitlets import Instance, Type, default @@ -179,8 +183,12 @@ def _dispatch_to_kernel(self, msg): stream = kernel.shell_stream self.session.send(stream, msg) msg_parts = stream.recv_multipart() - loop = asyncio.get_event_loop() - loop.run_until_complete(kernel.dispatch_shell(msg_parts)) + if run_sync: + dispatch_shell = run_sync(kernel.dispatch_shell) + dispatch_shell(msg_parts) + else: + loop = asyncio.get_event_loop() + loop.run_until_complete(kernel.dispatch_shell(msg_parts)) idents, reply_msg = self.session.recv(stream, copy=False) self.shell_channel.call_handlers_later(reply_msg) From 10126735d87c535daa87499ce320bce6a1a89159 Mon Sep 17 00:00:00 2001 From: Steven Silvester Date: Wed, 21 Sep 2022 10:37:42 -0500 Subject: [PATCH 2/3] fix lint --- ipykernel/inprocess/client.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/ipykernel/inprocess/client.py b/ipykernel/inprocess/client.py index 04627950a..53db84f8b 100644 --- a/ipykernel/inprocess/client.py +++ b/ipykernel/inprocess/client.py @@ -15,10 +15,11 @@ from jupyter_client.client import KernelClient from jupyter_client.clientabc import KernelClientABC + try: from jupyter_client.utils import run_sync # requires 7.0+ except ImportError: - run_sync = None + run_sync = None # type:ignore # IPython imports from traitlets import Instance, Type, default From 684dec7b80a52cb977afc92a23cc55679ba5c7d5 Mon Sep 17 00:00:00 2001 From: Steven Silvester Date: Sat, 24 Sep 2022 20:27:31 -0500 Subject: [PATCH 3/3] Remove client branch install --- .github/workflows/ci.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index aeeb5611e..8464830c8 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -198,7 +198,6 @@ jobs: pip check - name: Run the tests run: | - pip install jupyter_client@https://github.com/blink1073/jupyter_client/archive/refs/heads/synchronous_managers.zip cmd="python -m pytest -vv" $cmd || $cmd --lf