Show More
@@ -228,7 +228,7 b' class FrontendWidget(HistoryConsoleWidget, BaseFrontendMixin):' | |||||
228 |
|
228 | |||
229 | elif key == QtCore.Qt.Key_Period: |
|
229 | elif key == QtCore.Qt.Key_Period: | |
230 | message = 'Are you sure you want to restart the kernel?' |
|
230 | message = 'Are you sure you want to restart the kernel?' | |
231 |
self.restart_kernel(message, |
|
231 | self.restart_kernel(message, now=False) | |
232 | return True |
|
232 | return True | |
233 |
|
233 | |||
234 | elif not event.modifiers() & QtCore.Qt.AltModifier: |
|
234 | elif not event.modifiers() & QtCore.Qt.AltModifier: | |
@@ -322,7 +322,7 b' class FrontendWidget(HistoryConsoleWidget, BaseFrontendMixin):' | |||||
322 | if self.custom_restart: |
|
322 | if self.custom_restart: | |
323 | self.custom_restart_kernel_died.emit(since_last_heartbeat) |
|
323 | self.custom_restart_kernel_died.emit(since_last_heartbeat) | |
324 | else: |
|
324 | else: | |
325 |
self.restart_kernel(message, |
|
325 | self.restart_kernel(message, now=True) | |
326 |
|
326 | |||
327 | def _handle_object_info_reply(self, rep): |
|
327 | def _handle_object_info_reply(self, rep): | |
328 | """ Handle replies for call tips. |
|
328 | """ Handle replies for call tips. | |
@@ -395,10 +395,10 b' class FrontendWidget(HistoryConsoleWidget, BaseFrontendMixin):' | |||||
395 | self._append_plain_text('Kernel process is either remote or ' |
|
395 | self._append_plain_text('Kernel process is either remote or ' | |
396 | 'unspecified. Cannot interrupt.\n') |
|
396 | 'unspecified. Cannot interrupt.\n') | |
397 |
|
397 | |||
398 |
def restart_kernel(self, message, |
|
398 | def restart_kernel(self, message, now=False): | |
399 | """ Attempts to restart the running kernel. |
|
399 | """ Attempts to restart the running kernel. | |
400 | """ |
|
400 | """ | |
401 |
# FIXME: |
|
401 | # FIXME: now should be configurable via a checkbox in the | |
402 | # dialog. Right now at least the heartbeat path sets it to True and |
|
402 | # dialog. Right now at least the heartbeat path sets it to True and | |
403 | # the manual restart to False. But those should just be the |
|
403 | # the manual restart to False. But those should just be the | |
404 | # pre-selected states of a checkbox that the user could override if so |
|
404 | # pre-selected states of a checkbox that the user could override if so | |
@@ -421,8 +421,7 b' class FrontendWidget(HistoryConsoleWidget, BaseFrontendMixin):' | |||||
421 | message, buttons) |
|
421 | message, buttons) | |
422 | if result == QtGui.QMessageBox.Yes: |
|
422 | if result == QtGui.QMessageBox.Yes: | |
423 | try: |
|
423 | try: | |
424 | self.kernel_manager.restart_kernel( |
|
424 | self.kernel_manager.restart_kernel(now=now) | |
425 | instant_death=instant_death) |
|
|||
426 | except RuntimeError: |
|
425 | except RuntimeError: | |
427 | message = 'Kernel started externally. Cannot restart.\n' |
|
426 | message = 'Kernel started externally. Cannot restart.\n' | |
428 | self._append_plain_text(message) |
|
427 | self._append_plain_text(message) |
@@ -757,14 +757,14 b' class KernelManager(HasTraits):' | |||||
757 | if self.has_kernel: |
|
757 | if self.has_kernel: | |
758 | self.kill_kernel() |
|
758 | self.kill_kernel() | |
759 |
|
759 | |||
760 |
def restart_kernel(self, |
|
760 | def restart_kernel(self, now=False): | |
761 | """Restarts a kernel with the same arguments that were used to launch |
|
761 | """Restarts a kernel with the same arguments that were used to launch | |
762 | it. If the old kernel was launched with random ports, the same ports |
|
762 | it. If the old kernel was launched with random ports, the same ports | |
763 | will be used for the new kernel. |
|
763 | will be used for the new kernel. | |
764 |
|
764 | |||
765 | Parameters |
|
765 | Parameters | |
766 | ---------- |
|
766 | ---------- | |
767 |
|
|
767 | now : bool, optional | |
768 | If True, the kernel is forcefully restarted *immediately*, without |
|
768 | If True, the kernel is forcefully restarted *immediately*, without | |
769 | having a chance to do any cleanup action. Otherwise the kernel is |
|
769 | having a chance to do any cleanup action. Otherwise the kernel is | |
770 | given 1s to clean up before a forceful restart is issued. |
|
770 | given 1s to clean up before a forceful restart is issued. | |
@@ -777,7 +777,7 b' class KernelManager(HasTraits):' | |||||
777 | "No previous call to 'start_kernel'.") |
|
777 | "No previous call to 'start_kernel'.") | |
778 | else: |
|
778 | else: | |
779 | if self.has_kernel: |
|
779 | if self.has_kernel: | |
780 |
if |
|
780 | if now: | |
781 | self.kill_kernel() |
|
781 | self.kill_kernel() | |
782 | else: |
|
782 | else: | |
783 | self.shutdown_kernel() |
|
783 | self.shutdown_kernel() |
General Comments 0
You need to be logged in to leave comments.
Login now