Skip to content

Commit

Permalink
Add client 8 support (#996)
Browse files Browse the repository at this point in the history
  • Loading branch information
blink1073 authored Sep 25, 2022
1 parent b80e59e commit 92292ad
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions ipykernel/inprocess/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,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 # type:ignore

# IPython imports
from traitlets import Instance, Type, default

Expand Down Expand Up @@ -179,8 +184,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)

Expand Down

0 comments on commit 92292ad

Please sign in to comment.