Skip to content

Commit

Permalink
Fix in-process kernel.
Browse files Browse the repository at this point in the history
  • Loading branch information
SylvainCorlay committed Apr 14, 2021
1 parent 2ce1f41 commit 971383d
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
6 changes: 4 additions & 2 deletions ipykernel/inprocess/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@
# Imports
#-----------------------------------------------------------------------------

import asyncio

# IPython imports
from traitlets import Type, Instance, default
from jupyter_client.clientabc import KernelClientABC
Expand Down Expand Up @@ -173,8 +175,8 @@ def _dispatch_to_kernel(self, msg):
stream = kernel.shell_stream
self.session.send(stream, msg)
msg_parts = stream.recv_multipart()
kernel.dispatch_shell(msg_parts)

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
6 changes: 3 additions & 3 deletions ipykernel/inprocess/ipkernel.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
# Copyright (c) IPython Development Team.
# Distributed under the terms of the Modified BSD License.

from contextlib import asynccontextmanager
from contextlib import contextmanager
import logging
import sys

Expand Down Expand Up @@ -76,7 +76,7 @@ def __init__(self, **traits):

async def execute_request(self, stream, ident, parent):
""" Override for temporary IO redirection. """
async with self._redirected_io():
with self._redirected_io():
await super(InProcessKernel, self).execute_request(stream, ident, parent)

def start(self):
Expand Down Expand Up @@ -113,7 +113,7 @@ def _input_request(self, prompt, ident, parent, password=False):
# Protected interface
#-------------------------------------------------------------------------

@asynccontextmanager
@contextmanager
def _redirected_io(self):
""" Temporarily redirect IO to the kernel.
"""
Expand Down

0 comments on commit 971383d

Please sign in to comment.