|
80 | 80 |
|
81 | 81 |
|
82 | 82 | # jupyter_client 7.0+ has async channel methods that we expect to be sync here
|
| 83 | +# also, `block` was removed from `get_msg()` |
83 | 84 | if jupyter_client._version.version_info[0] >= 7:
|
84 | 85 | from jupyter_client.utils import run_sync
|
| 86 | + JUPYTER_CLIENT_7 = True |
85 | 87 | else:
|
86 | 88 | run_sync = lambda x: x
|
| 89 | + JUPYTER_CLIENT_7 = False |
87 | 90 |
|
88 | 91 |
|
89 | 92 | def ask_yes_no(prompt, default=None, interrupt=None):
|
@@ -748,7 +751,10 @@ def run_cell(self, cell, store_history=True):
|
748 | 751 | #-----------------
|
749 | 752 |
|
750 | 753 | 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) |
752 | 758 | if msg["parent_header"].get("msg_id", None) == msg_id:
|
753 | 759 |
|
754 | 760 | self.handle_iopub(msg_id)
|
@@ -787,7 +793,10 @@ def handle_is_complete_reply(self, msg_id, timeout=None):
|
787 | 793 | ## Get the is_complete response:
|
788 | 794 | msg = None
|
789 | 795 | 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) |
791 | 800 | except Empty:
|
792 | 801 | warn('The kernel did not respond to an is_complete_request. '
|
793 | 802 | 'Setting `use_kernel_is_complete` to False.')
|
|
0 commit comments