##// END OF EJS Templates
Merge pull request #4542 from ivanov/history-clear...
Merge pull request #4542 from ivanov/history-clear new `ipython history clear` subcommand This new subcommand is equivalent to ipython history trim --HistoryTrim.keep=0, which is now supported (and also has a more convenient --keep alias) This command comes with a fix to bash completion of flags for ipython history subcmd also included is a tiny fix for nbconvert completion that was pointed out by @jakobgager in #4528 also included is a change to our utils.io.ask_yes_no function that allows for specifying the behavior of a KeyboardInterrupt.

File last commit:

r11130:de5468b5
r13694:24e10561 merge
Show More
restarter.py
54 lines | 1.7 KiB | text/x-python | PythonLexer
Brian E. Granger
Adding KerelRestarter.
r10278 """A basic in process kernel monitor with autorestarting.
This watches a kernel's state using KernelManager.is_alive and auto
restarts the kernel if it dies.
"""
#-----------------------------------------------------------------------------
# Copyright (C) 2013 The IPython Development Team
#
# Distributed under the terms of the BSD License. The full license is in
# the file COPYING, distributed as part of this software.
#-----------------------------------------------------------------------------
#-----------------------------------------------------------------------------
# Imports
#-----------------------------------------------------------------------------
Brian Granger
Adding absolute import to kernelrestarter.
r10281 from __future__ import absolute_import
Brian E. Granger
Adding KerelRestarter.
r10278 from zmq.eventloop import ioloop
MinRK
cleanup boundaries of MultiKernelManager and KernelRestarter classes...
r10295 from IPython.kernel.restarter import KernelRestarter
Brian E. Granger
Adding KerelRestarter.
r10278 from IPython.utils.traitlets import (
Thomas Kluyver
Remove unused imports in IPython.kernel
r11130 Instance,
Brian E. Granger
Adding KerelRestarter.
r10278 )
#-----------------------------------------------------------------------------
# Code
#-----------------------------------------------------------------------------
MinRK
cleanup boundaries of MultiKernelManager and KernelRestarter classes...
r10295 class IOLoopKernelRestarter(KernelRestarter):
Brian E. Granger
Adding KerelRestarter.
r10278 """Monitor and autorestart a kernel."""
loop = Instance('zmq.eventloop.ioloop.IOLoop', allow_none=False)
def _loop_default(self):
return ioloop.IOLoop.instance()
Brian Granger
More work on autorestarting.
r10280 _pcallback = None
Brian E. Granger
Adding KerelRestarter.
r10278 def start(self):
Brian Granger
More work on autorestarting.
r10280 """Start the polling of the kernel."""
if self._pcallback is None:
self._pcallback = ioloop.PeriodicCallback(
MinRK
cleanup boundaries of MultiKernelManager and KernelRestarter classes...
r10295 self.poll, 1000*self.time_to_dead, self.loop
Brian Granger
More work on autorestarting.
r10280 )
MinRK
cleanup restart logic...
r10320 self._pcallback.start()
Brian Granger
More work on autorestarting.
r10280
def stop(self):
"""Stop the kernel polling."""
if self._pcallback is not None:
self._pcallback.stop()
MinRK
cleanup restart logic...
r10320 self._pcallback = None
Brian E. Granger
Adding KerelRestarter.
r10278