|
76 | 76 | from pygments.util import ClassNotFound
|
77 | 77 | from pygments.token import Token
|
78 | 78 |
|
| 79 | +from jupyter_client.utils import run_sync |
| 80 | + |
79 | 81 |
|
80 | 82 | def ask_yes_no(prompt, default=None, interrupt=None):
|
81 | 83 | """Asks a question and returns a boolean (y/n) answer.
|
@@ -705,8 +707,8 @@ def run_cell(self, cell, store_history=True):
|
705 | 707 | return
|
706 | 708 |
|
707 | 709 | # flush stale replies, which could have been ignored, due to missed heartbeats
|
708 |
| - while self.client.shell_channel.msg_ready(): |
709 |
| - self.client.shell_channel.get_msg() |
| 710 | + while run_sync(self.client.shell_channel.msg_ready)(): |
| 711 | + run_sync(self.client.shell_channel.get_msg)() |
710 | 712 | # execute takes 'hidden', which is the inverse of store_hist
|
711 | 713 | msg_id = self.client.execute(cell, not store_history)
|
712 | 714 |
|
@@ -739,7 +741,7 @@ def run_cell(self, cell, store_history=True):
|
739 | 741 | #-----------------
|
740 | 742 |
|
741 | 743 | def handle_execute_reply(self, msg_id, timeout=None):
|
742 |
| - msg = self.client.shell_channel.get_msg(block=False, timeout=timeout) |
| 744 | + msg = run_sync(self.client.shell_channel.get_msg)(block=False, timeout=timeout) |
743 | 745 | if msg["parent_header"].get("msg_id", None) == msg_id:
|
744 | 746 |
|
745 | 747 | self.handle_iopub(msg_id)
|
@@ -778,7 +780,7 @@ def handle_is_complete_reply(self, msg_id, timeout=None):
|
778 | 780 | ## Get the is_complete response:
|
779 | 781 | msg = None
|
780 | 782 | try:
|
781 |
| - msg = self.client.shell_channel.get_msg(block=True, timeout=timeout) |
| 783 | + msg = run_sync(self.client.shell_channel.get_msg)(block=True, timeout=timeout) |
782 | 784 | except Empty:
|
783 | 785 | warn('The kernel did not respond to an is_complete_request. '
|
784 | 786 | 'Setting `use_kernel_is_complete` to False.')
|
@@ -849,8 +851,8 @@ def handle_iopub(self, msg_id=''):
|
849 | 851 |
|
850 | 852 | It only displays output that is caused by this session.
|
851 | 853 | """
|
852 |
| - while self.client.iopub_channel.msg_ready(): |
853 |
| - sub_msg = self.client.iopub_channel.get_msg() |
| 854 | + while run_sync(self.client.iopub_channel.msg_ready)(): |
| 855 | + sub_msg = run_sync(self.client.iopub_channel.get_msg)() |
854 | 856 | msg_type = sub_msg['header']['msg_type']
|
855 | 857 |
|
856 | 858 | # Update execution_count in case it changed in another session
|
@@ -1003,7 +1005,7 @@ def handle_image_callable(self, data, mime):
|
1003 | 1005 | def handle_input_request(self, msg_id, timeout=0.1):
|
1004 | 1006 | """ Method to capture raw_input
|
1005 | 1007 | """
|
1006 |
| - req = self.client.stdin_channel.get_msg(timeout=timeout) |
| 1008 | + req = run_sync(self.client.stdin_channel.get_msg)(timeout=timeout) |
1007 | 1009 | # in case any iopub came while we were waiting:
|
1008 | 1010 | self.handle_iopub(msg_id)
|
1009 | 1011 | if msg_id == req["parent_header"].get("msg_id"):
|
|
0 commit comments