##// END OF EJS Templates
retry aborted history requests in qtconsole
MinRK -
Show More
@@ -12,6 +12,7 b' import os.path'
12 12 import re
13 13 from subprocess import Popen
14 14 import sys
15 import time
15 16 from textwrap import dedent
16 17
17 18 # System library imports
@@ -104,6 +105,7 b' class IPythonWidget(FrontendWidget):'
104 105 _payload_source_exit = zmq_shell_source + '.ask_exit'
105 106 _payload_source_next_input = zmq_shell_source + '.set_next_input'
106 107 _payload_source_page = 'IPython.zmq.page.page'
108 _retrying_history_request = False
107 109
108 110 #---------------------------------------------------------------------------
109 111 # 'object' interface
@@ -177,7 +179,21 b' class IPythonWidget(FrontendWidget):'
177 179 content = msg['content']
178 180 if 'history' not in content:
179 181 self.log.error("History request failed: %r"%content)
182 if content.get('status', '') == 'aborted' and \
183 not self._retrying_history_request:
184 # a *different* action caused this request to be aborted, so
185 # we should try again.
186 self.log.error("Retrying aborted history request")
187 # prevent multiple retries of aborted requests:
188 self._retrying_history_request = True
189 # wait out the kernel's queue flush, which is currently timed at 0.1s
190 time.sleep(0.25)
191 self.kernel_manager.shell_channel.history(hist_access_type='tail',n=1000)
192 else:
193 self._retrying_history_request = False
180 194 return
195 # reset retry flag
196 self._retrying_history_request = False
181 197 history_items = content['history']
182 198 items = [ line.rstrip() for _, _, line in history_items ]
183 199 self._set_history(items)
General Comments 0
You need to be logged in to leave comments. Login now