Show More
@@ -16,7 +16,7 b' from unicodedata import category' | |||||
16 | from IPython.external.qt import QtCore, QtGui |
|
16 | from IPython.external.qt import QtCore, QtGui | |
17 |
|
17 | |||
18 | # Local imports |
|
18 | # Local imports | |
19 | from IPython.config.configurable import Configurable |
|
19 | from IPython.config.configurable import LoggingConfigurable | |
20 | from IPython.frontend.qt.rich_text import HtmlExporter |
|
20 | from IPython.frontend.qt.rich_text import HtmlExporter | |
21 | from IPython.frontend.qt.util import MetaQObjectHasTraits, get_font |
|
21 | from IPython.frontend.qt.util import MetaQObjectHasTraits, get_font | |
22 | from IPython.utils.text import columnize |
|
22 | from IPython.utils.text import columnize | |
@@ -39,7 +39,7 b' def is_letter_or_number(char):' | |||||
39 | # Classes |
|
39 | # Classes | |
40 | #----------------------------------------------------------------------------- |
|
40 | #----------------------------------------------------------------------------- | |
41 |
|
41 | |||
42 | class ConsoleWidget(Configurable, QtGui.QWidget): |
|
42 | class ConsoleWidget(LoggingConfigurable, QtGui.QWidget): | |
43 | """ An abstract base class for console-type widgets. This class has |
|
43 | """ An abstract base class for console-type widgets. This class has | |
44 | functionality for: |
|
44 | functionality for: | |
45 |
|
45 | |||
@@ -170,7 +170,7 b' class ConsoleWidget(Configurable, QtGui.QWidget):' | |||||
170 | The parent for this widget. |
|
170 | The parent for this widget. | |
171 | """ |
|
171 | """ | |
172 | QtGui.QWidget.__init__(self, parent) |
|
172 | QtGui.QWidget.__init__(self, parent) | |
173 | Configurable.__init__(self, **kw) |
|
173 | LoggingConfigurable.__init__(self, **kw) | |
174 |
|
174 | |||
175 | # Create the layout and underlying text widget. |
|
175 | # Create the layout and underlying text widget. | |
176 | layout = QtGui.QStackedLayout(self) |
|
176 | layout = QtGui.QStackedLayout(self) |
@@ -12,6 +12,7 b' import os.path' | |||||
12 | import re |
|
12 | import re | |
13 | from subprocess import Popen |
|
13 | from subprocess import Popen | |
14 | import sys |
|
14 | import sys | |
|
15 | import time | |||
15 | from textwrap import dedent |
|
16 | from textwrap import dedent | |
16 |
|
17 | |||
17 | # System library imports |
|
18 | # System library imports | |
@@ -104,6 +105,7 b' class IPythonWidget(FrontendWidget):' | |||||
104 | _payload_source_exit = zmq_shell_source + '.ask_exit' |
|
105 | _payload_source_exit = zmq_shell_source + '.ask_exit' | |
105 | _payload_source_next_input = zmq_shell_source + '.set_next_input' |
|
106 | _payload_source_next_input = zmq_shell_source + '.set_next_input' | |
106 | _payload_source_page = 'IPython.zmq.page.page' |
|
107 | _payload_source_page = 'IPython.zmq.page.page' | |
|
108 | _retrying_history_request = False | |||
107 |
|
109 | |||
108 | #--------------------------------------------------------------------------- |
|
110 | #--------------------------------------------------------------------------- | |
109 | # 'object' interface |
|
111 | # 'object' interface | |
@@ -174,7 +176,25 b' class IPythonWidget(FrontendWidget):' | |||||
174 | """ Implemented to handle history tail replies, which are only supported |
|
176 | """ Implemented to handle history tail replies, which are only supported | |
175 | by the IPython kernel. |
|
177 | by the IPython kernel. | |
176 | """ |
|
178 | """ | |
177 |
|
|
179 | content = msg['content'] | |
|
180 | if 'history' not in content: | |||
|
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 | |||
|
194 | return | |||
|
195 | # reset retry flag | |||
|
196 | self._retrying_history_request = False | |||
|
197 | history_items = content['history'] | |||
178 | items = [ line.rstrip() for _, _, line in history_items ] |
|
198 | items = [ line.rstrip() for _, _, line in history_items ] | |
179 | self._set_history(items) |
|
199 | self._set_history(items) | |
180 |
|
200 |
General Comments 0
You need to be logged in to leave comments.
Login now