##// END OF EJS Templates
remove redundant time_to_dead from IOLoopKernelRestarter
MinRK -
Show More
@@ -1,59 +1,55 b''
1 1 """A basic in process kernel monitor with autorestarting.
2 2
3 3 This watches a kernel's state using KernelManager.is_alive and auto
4 4 restarts the kernel if it dies.
5 5 """
6 6
7 7 #-----------------------------------------------------------------------------
8 8 # Copyright (C) 2013 The IPython Development Team
9 9 #
10 10 # Distributed under the terms of the BSD License. The full license is in
11 11 # the file COPYING, distributed as part of this software.
12 12 #-----------------------------------------------------------------------------
13 13
14 14 #-----------------------------------------------------------------------------
15 15 # Imports
16 16 #-----------------------------------------------------------------------------
17 17
18 18 from __future__ import absolute_import
19 19
20 20 import zmq
21 21 from zmq.eventloop import ioloop
22 22
23 23
24 24 from IPython.kernel.restarter import KernelRestarter
25 25 from IPython.utils.traitlets import (
26 26 Instance, Float, List,
27 27 )
28 28
29 29 #-----------------------------------------------------------------------------
30 30 # Code
31 31 #-----------------------------------------------------------------------------
32 32
33 33 class IOLoopKernelRestarter(KernelRestarter):
34 34 """Monitor and autorestart a kernel."""
35 35
36 36 loop = Instance('zmq.eventloop.ioloop.IOLoop', allow_none=False)
37 37 def _loop_default(self):
38 38 return ioloop.IOLoop.instance()
39 39
40 time_to_dead = Float(3.0, config=True,
41 help="""Kernel heartbeat interval in seconds."""
42 )
43
44 40 _pcallback = None
45 41
46 42 def start(self):
47 43 """Start the polling of the kernel."""
48 44 if self._pcallback is None:
49 45 self._pcallback = ioloop.PeriodicCallback(
50 46 self.poll, 1000*self.time_to_dead, self.loop
51 47 )
52 48 self._pcallback.start()
53 49
54 50 def stop(self):
55 51 """Stop the kernel polling."""
56 52 if self._pcallback is not None:
57 53 self._pcallback.stop()
58 54 self._pcallback = None
59 55
General Comments 0
You need to be logged in to leave comments. Login now