Skip to content

Commit 7f2dc91

Browse files
committed
Drop block kwarg from get_msg() for jupyter_client>=7.0
1 parent 6620bdb commit 7f2dc91

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

jupyter_console/ptshell.py

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -80,10 +80,13 @@
8080

8181

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

8891

8992
def ask_yes_no(prompt, default=None, interrupt=None):
@@ -748,7 +751,10 @@ def run_cell(self, cell, store_history=True):
748751
#-----------------
749752

750753
def handle_execute_reply(self, msg_id, timeout=None):
751-
msg = run_sync(self.client.shell_channel.get_msg)(block=False, timeout=timeout)
754+
kwargs = {"timeout": timeout}
755+
if not JUPYTER_CLIENT_7:
756+
kwargs["block"] = False
757+
msg = run_sync(self.client.shell_channel.get_msg)(**kwargs)
752758
if msg["parent_header"].get("msg_id", None) == msg_id:
753759

754760
self.handle_iopub(msg_id)
@@ -787,7 +793,10 @@ def handle_is_complete_reply(self, msg_id, timeout=None):
787793
## Get the is_complete response:
788794
msg = None
789795
try:
790-
msg = run_sync(self.client.shell_channel.get_msg)(block=True, timeout=timeout)
796+
kwargs = {"timeout": timeout}
797+
if not JUPYTER_CLIENT_7:
798+
kwargs["block"] = True
799+
msg = run_sync(self.client.shell_channel.get_msg)(**kwargs)
791800
except Empty:
792801
warn('The kernel did not respond to an is_complete_request. '
793802
'Setting `use_kernel_is_complete` to False.')

0 commit comments

Comments
 (0)