##// END OF EJS Templates
Merge pull request #6363 from minrk/debug-heartbeat...
Thomas Kluyver -
r17771:5efa769d merge
parent child Browse files
Show More
@@ -6,31 +6,27 b' restarts the kernel if it dies.'
6 6 It is an incomplete base class, and must be subclassed.
7 7 """
8 8
9 #-----------------------------------------------------------------------------
10 # Copyright (C) 2013 The IPython Development Team
11 #
12 # Distributed under the terms of the BSD License. The full license is in
13 # the file COPYING, distributed as part of this software.
14 #-----------------------------------------------------------------------------
15
16 #-----------------------------------------------------------------------------
17 # Imports
18 #-----------------------------------------------------------------------------
9 # Copyright (c) IPython Development Team.
10 # Distributed under the terms of the Modified BSD License.
19 11
20 12 from IPython.config.configurable import LoggingConfigurable
21 13 from IPython.utils.traitlets import (
22 14 Instance, Float, Dict, Bool, Integer,
23 15 )
24 16
25 #-----------------------------------------------------------------------------
26 # Code
27 #-----------------------------------------------------------------------------
28 17
29 18 class KernelRestarter(LoggingConfigurable):
30 19 """Monitor and autorestart a kernel."""
31 20
32 21 kernel_manager = Instance('IPython.kernel.KernelManager')
33
22
23 debug = Bool(False, config=True,
24 help="""Whether to include every poll event in debugging output.
25
26 Has to be set explicitly, because there will be *a lot* of output.
27 """
28 )
29
34 30 time_to_dead = Float(3.0, config=True,
35 31 help="""Kernel heartbeat interval in seconds."""
36 32 )
@@ -87,7 +83,8 b' class KernelRestarter(LoggingConfigurable):'
87 83 self.log.error("KernelRestarter: %s callback %r failed", event, callback, exc_info=True)
88 84
89 85 def poll(self):
90 self.log.debug('Polling kernel...')
86 if self.debug:
87 self.log.debug('Polling kernel...')
91 88 if not self.kernel_manager.is_alive():
92 89 if self._restarting:
93 90 self._restart_count += 1
@@ -2,17 +2,10 b''
2 2 """
3 3 A multi-heart Heartbeat system using PUB and ROUTER sockets. pings are sent out on the PUB,
4 4 and hearts are tracked based on their DEALER identities.
5
6 Authors:
7
8 * Min RK
9 5 """
10 #-----------------------------------------------------------------------------
11 # Copyright (C) 2010-2011 The IPython Development Team
12 #
13 # Distributed under the terms of the BSD License. The full license is in
14 # the file COPYING, distributed as part of this software.
15 #-----------------------------------------------------------------------------
6
7 # Copyright (c) IPython Development Team.
8 # Distributed under the terms of the Modified BSD License.
16 9
17 10 from __future__ import print_function
18 11 import time
@@ -24,7 +17,7 b' from zmq.eventloop import ioloop, zmqstream'
24 17
25 18 from IPython.config.configurable import LoggingConfigurable
26 19 from IPython.utils.py3compat import str_to_bytes
27 from IPython.utils.traitlets import Set, Instance, CFloat, Integer, Dict
20 from IPython.utils.traitlets import Set, Instance, CFloat, Integer, Dict, Bool
28 21
29 22 from IPython.parallel.util import log_errors
30 23
@@ -69,7 +62,13 b' class HeartMonitor(LoggingConfigurable):'
69 62 pingstream: a PUB stream
70 63 pongstream: an ROUTER stream
71 64 period: the period of the heartbeat in milliseconds"""
72
65
66 debug = Bool(False, config=True,
67 help="""Whether to include every heartbeat in debugging output.
68
69 Has to be set explicitly, because there will be *a lot* of output.
70 """
71 )
73 72 period = Integer(3000, config=True,
74 73 help='The frequency at which the Hub pings the engines for heartbeats '
75 74 '(in ms)',
@@ -121,7 +120,8 b' class HeartMonitor(LoggingConfigurable):'
121 120 toc = time.time()
122 121 self.lifetime += toc-self.tic
123 122 self.tic = toc
124 self.log.debug("heartbeat::sending %s", self.lifetime)
123 if self.debug:
124 self.log.debug("heartbeat::sending %s", self.lifetime)
125 125 goodhearts = self.hearts.intersection(self.responses)
126 126 missed_beats = self.hearts.difference(goodhearts)
127 127 newhearts = self.responses.difference(goodhearts)
@@ -181,7 +181,8 b' class HeartMonitor(LoggingConfigurable):'
181 181 last = str_to_bytes(str(self.last_ping))
182 182 if msg[1] == current:
183 183 delta = time.time()-self.tic
184 # self.log.debug("heartbeat::heart %r took %.2f ms to respond"%(msg[0], 1000*delta))
184 if self.debug:
185 self.log.debug("heartbeat::heart %r took %.2f ms to respond", msg[0], 1000*delta)
185 186 self.responses.add(msg[0])
186 187 elif msg[1] == last:
187 188 delta = time.time()-self.tic + (self.lifetime-self.last_ping)
General Comments 0
You need to be logged in to leave comments. Login now