Show More
@@ -508,7 +508,7 b' class FrontendWidget(HistoryConsoleWidget, BaseFrontendMixin):' | |||||
508 | time.sleep(0.25) # wait 1/4 sec to reset |
|
508 | time.sleep(0.25) # wait 1/4 sec to reset | |
509 | # lest the request for a new prompt |
|
509 | # lest the request for a new prompt | |
510 | # goes to the old kernel |
|
510 | # goes to the old kernel | |
511 |
self.reset |
|
511 | self.reset() | |
512 | else: # remote kernel, prompt on Kernel shutdown/reset |
|
512 | else: # remote kernel, prompt on Kernel shutdown/reset | |
513 | title = self.window().windowTitle() |
|
513 | title = self.window().windowTitle() | |
514 | if not msg['content']['restart']: |
|
514 | if not msg['content']['restart']: | |
@@ -534,7 +534,7 b' class FrontendWidget(HistoryConsoleWidget, BaseFrontendMixin):' | |||||
534 | """ Called when the KernelManager channels have started listening or |
|
534 | """ Called when the KernelManager channels have started listening or | |
535 | when the frontend is assigned an already listening KernelManager. |
|
535 | when the frontend is assigned an already listening KernelManager. | |
536 | """ |
|
536 | """ | |
537 | self.reset() |
|
537 | self.reset(force=True) | |
538 |
|
538 | |||
539 | #--------------------------------------------------------------------------- |
|
539 | #--------------------------------------------------------------------------- | |
540 | # 'FrontendWidget' public interface |
|
540 | # 'FrontendWidget' public interface | |
@@ -568,9 +568,13 b' class FrontendWidget(HistoryConsoleWidget, BaseFrontendMixin):' | |||||
568 | self._append_plain_text('Kernel process is either remote or ' |
|
568 | self._append_plain_text('Kernel process is either remote or ' | |
569 | 'unspecified. Cannot interrupt.\n') |
|
569 | 'unspecified. Cannot interrupt.\n') | |
570 |
|
570 | |||
571 | def reset(self): |
|
571 | def reset(self, force=False): | |
572 |
""" Resets the widget to its initial state |
|
572 | """ Resets the widget to its initial state if ``force`` parameter or | |
573 | also re-writes the banner and aborts execution if necessary. |
|
573 | ``clear_on_kernel_restart`` configuration setting is True, otherwise | |
|
574 | prints a visual indication of the fact that the kernel restarted, but | |||
|
575 | does not clear the traces from previous usage of the kernel before it | |||
|
576 | was restarted. With ``force=True``, it is similar to ``clear``, but | |||
|
577 | also re-writes the banner and aborts execution if necessary. | |||
574 | """ |
|
578 | """ | |
575 | if self._executing: |
|
579 | if self._executing: | |
576 | self._executing = False |
|
580 | self._executing = False | |
@@ -578,29 +582,19 b' class FrontendWidget(HistoryConsoleWidget, BaseFrontendMixin):' | |||||
578 | self._reading = False |
|
582 | self._reading = False | |
579 | self._highlighter.highlighting_on = False |
|
583 | self._highlighter.highlighting_on = False | |
580 |
|
584 | |||
581 | self._control.clear() |
|
585 | if self.clear_on_kernel_restart or force: | |
582 | self._append_plain_text(self.banner) |
|
586 | self._control.clear() | |
583 | # update output marker for stdout/stderr, so that startup |
|
587 | self._append_plain_text(self.banner) | |
584 | # messages appear after banner: |
|
|||
585 | self._append_before_prompt_pos = self._get_cursor().position() |
|
|||
586 | self._show_interpreter_prompt() |
|
|||
587 |
|
||||
588 | def reset_on_restart(self): |
|
|||
589 | """Resets the widget if ``clear_on_kernel_restart`` is True, otherwise |
|
|||
590 | prints a visual indication of the fact that the kernel restarted, but |
|
|||
591 | does not clear the traces from previous usage of the kernel before it |
|
|||
592 | was restarted. |
|
|||
593 | """ |
|
|||
594 | if self.clear_on_kernel_restart: |
|
|||
595 | self.reset() |
|
|||
596 | else: |
|
588 | else: | |
597 | self._append_before_prompt_pos = self._get_cursor().position() |
|
|||
598 | self._append_plain_text("# restarting kernel...") |
|
589 | self._append_plain_text("# restarting kernel...") | |
599 | self._append_html("<hr><br>") |
|
590 | self._append_html("<hr><br>") | |
600 | # XXX: Reprinting the full banner may be too much, but once #1680 is |
|
591 | # XXX: Reprinting the full banner may be too much, but once #1680 is | |
601 | # addressed, that will mitigate it. |
|
592 | # addressed, that will mitigate it. | |
602 | #self._append_plain_text(self.banner) |
|
593 | #self._append_plain_text(self.banner) | |
603 | self._show_interpreter_prompt() |
|
594 | # update output marker for stdout/stderr, so that startup | |
|
595 | # messages appear after banner: | |||
|
596 | self._append_before_prompt_pos = self._get_cursor().position() | |||
|
597 | self._show_interpreter_prompt() | |||
604 |
|
598 | |||
605 | def restart_kernel(self, message, now=False): |
|
599 | def restart_kernel(self, message, now=False): | |
606 | """ Attempts to restart the running kernel. |
|
600 | """ Attempts to restart the running kernel. | |
@@ -633,7 +627,7 b' class FrontendWidget(HistoryConsoleWidget, BaseFrontendMixin):' | |||||
633 | before_prompt=True |
|
627 | before_prompt=True | |
634 | ) |
|
628 | ) | |
635 | else: |
|
629 | else: | |
636 |
self.reset |
|
630 | self.reset() | |
637 | else: |
|
631 | else: | |
638 | self.kernel_manager.hb_channel.unpause() |
|
632 | self.kernel_manager.hb_channel.unpause() | |
639 |
|
633 |
General Comments 0
You need to be logged in to leave comments.
Login now