|
76 | 76 | from pygments.util import ClassNotFound |
77 | 77 | from pygments.token import Token |
78 | 78 |
|
79 | | -import jupyter_client |
80 | | - |
81 | | - |
82 | | -# jupyter_client 7.0+ has async channel methods that we expect to be sync here |
83 | | -# also, `block` was removed from `get_msg()` |
84 | | -if jupyter_client._version.version_info[0] >= 7: |
85 | | - from jupyter_client.utils import run_sync |
86 | | - JUPYTER_CLIENT_7 = True |
87 | | -else: |
88 | | - run_sync = lambda x: x |
89 | | - JUPYTER_CLIENT_7 = False |
| 79 | +from jupyter_client.utils import run_sync |
90 | 80 |
|
91 | 81 |
|
92 | 82 | def ask_yes_no(prompt, default=None, interrupt=None): |
@@ -752,8 +742,6 @@ def run_cell(self, cell, store_history=True): |
752 | 742 |
|
753 | 743 | def handle_execute_reply(self, msg_id, timeout=None): |
754 | 744 | kwargs = {"timeout": timeout} |
755 | | - if not JUPYTER_CLIENT_7: |
756 | | - kwargs["block"] = False |
757 | 745 | msg = run_sync(self.client.shell_channel.get_msg)(**kwargs) |
758 | 746 | if msg["parent_header"].get("msg_id", None) == msg_id: |
759 | 747 |
|
@@ -794,8 +782,6 @@ def handle_is_complete_reply(self, msg_id, timeout=None): |
794 | 782 | msg = None |
795 | 783 | try: |
796 | 784 | kwargs = {"timeout": timeout} |
797 | | - if not JUPYTER_CLIENT_7: |
798 | | - kwargs["block"] = True |
799 | 785 | msg = run_sync(self.client.shell_channel.get_msg)(**kwargs) |
800 | 786 | except Empty: |
801 | 787 | warn('The kernel did not respond to an is_complete_request. ' |
@@ -852,11 +838,9 @@ def include_output(self, msg): |
852 | 838 |
|
853 | 839 | async def handle_external_iopub(self, loop=None): |
854 | 840 | while self.keep_running: |
855 | | - # we need to check for keep_running from time to time as |
856 | | - # we are blocking in an executor block which cannot be cancelled. |
857 | | - poll_result = await loop.run_in_executor( |
858 | | - None, self.client.iopub_channel.socket.poll, 500) |
859 | | - if(poll_result): |
| 841 | + # we need to check for keep_running from time to time |
| 842 | + poll_result = await self.client.iopub_channel.socket.poll(500) |
| 843 | + if poll_result: |
860 | 844 | self.handle_iopub() |
861 | 845 |
|
862 | 846 | def handle_iopub(self, msg_id=''): |
|
0 commit comments