Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Require jupyter_client>=7.0.0 #266

Merged
merged 1 commit into from
Mar 7, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 1 addition & 8 deletions jupyter_console/completer.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,7 @@
from traitlets.config import Configurable
from traitlets import Float

import jupyter_client


# jupyter_client 7.0+ has async channel methods that we expect to be sync here
if jupyter_client.version_info >= (7,):
from jupyter_client.utils import run_sync
else:
run_sync = lambda x: x
from jupyter_client.utils import run_sync


class ZMQCompleter(Configurable):
Expand Down
24 changes: 4 additions & 20 deletions jupyter_console/ptshell.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,17 +76,7 @@
from pygments.util import ClassNotFound
from pygments.token import Token

import jupyter_client


# jupyter_client 7.0+ has async channel methods that we expect to be sync here
# also, `block` was removed from `get_msg()`
if jupyter_client._version.version_info[0] >= 7:
from jupyter_client.utils import run_sync
JUPYTER_CLIENT_7 = True
else:
run_sync = lambda x: x
JUPYTER_CLIENT_7 = False
from jupyter_client.utils import run_sync


def ask_yes_no(prompt, default=None, interrupt=None):
Expand Down Expand Up @@ -752,8 +742,6 @@ def run_cell(self, cell, store_history=True):

def handle_execute_reply(self, msg_id, timeout=None):
kwargs = {"timeout": timeout}
if not JUPYTER_CLIENT_7:
kwargs["block"] = False
msg = run_sync(self.client.shell_channel.get_msg)(**kwargs)
if msg["parent_header"].get("msg_id", None) == msg_id:

Expand Down Expand Up @@ -794,8 +782,6 @@ def handle_is_complete_reply(self, msg_id, timeout=None):
msg = None
try:
kwargs = {"timeout": timeout}
if not JUPYTER_CLIENT_7:
kwargs["block"] = True
msg = run_sync(self.client.shell_channel.get_msg)(**kwargs)
except Empty:
warn('The kernel did not respond to an is_complete_request. '
Expand Down Expand Up @@ -852,11 +838,9 @@ def include_output(self, msg):

async def handle_external_iopub(self, loop=None):
while self.keep_running:
# we need to check for keep_running from time to time as
# we are blocking in an executor block which cannot be cancelled.
poll_result = await loop.run_in_executor(
None, self.client.iopub_channel.socket.poll, 500)
if(poll_result):
# we need to check for keep_running from time to time
poll_result = await self.client.iopub_channel.socket.poll(500)
if poll_result:
self.handle_iopub()

def handle_iopub(self, msg_id=''):
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@
'Programming Language :: Python :: 3.9',
],
install_requires=[
'jupyter_client',
'jupyter_client>=7.0.0',
'ipython',
'ipykernel', # bless IPython kernel for now
'prompt_toolkit>=2.0.0,<3.1.0,!=3.0.0,!=3.0.1',
Expand Down