Skip to content

Commit

Permalink
Merge pull request #1312 from minrk/hb
Browse files Browse the repository at this point in the history
two small heartbeat changes:

* flush outgoing heartbeats (notebook and parallel):
  - Prevents mismatch between heartbeat timer and actual heartbeat send/recv events.

* relax default heartbeat period in IPython.parallel to 3s from 1s
  - Matches heartbeats elsewhere.  3s should be extremely conservative, as most heartbeat responses are O(1ms) unless there's a bug in our code (like the above flush and previously-discovered GIL issues).

closes #1304
  • Loading branch information
minrk committed Jan 23, 2012
2 parents 6bc0f53 + a4d4ccc commit 1487f2f
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
2 changes: 2 additions & 0 deletions IPython/frontend/html/notebook/handlers.py
Expand Up @@ -481,6 +481,8 @@ def ping_or_dead():
if self._kernel_alive: if self._kernel_alive:
self._kernel_alive = False self._kernel_alive = False
self.hb_stream.send(b'ping') self.hb_stream.send(b'ping')
# flush stream to force immediate socket send
self.hb_stream.flush()
else: else:
try: try:
callback() callback()
Expand Down
4 changes: 3 additions & 1 deletion IPython/parallel/controller/heartmonitor.py
Expand Up @@ -64,7 +64,7 @@ class HeartMonitor(LoggingConfigurable):
pongstream: an XREP stream pongstream: an XREP stream
period: the period of the heartbeat in milliseconds""" period: the period of the heartbeat in milliseconds"""


period = Integer(1000, config=True, period = Integer(3000, config=True,
help='The frequency at which the Hub pings the engines for heartbeats ' help='The frequency at which the Hub pings the engines for heartbeats '
'(in ms)', '(in ms)',
) )
Expand Down Expand Up @@ -124,6 +124,8 @@ def beat(self):
# print self.on_probation, self.hearts # print self.on_probation, self.hearts
# self.log.debug("heartbeat::beat %.3f, %i beating hearts", self.lifetime, len(self.hearts)) # self.log.debug("heartbeat::beat %.3f, %i beating hearts", self.lifetime, len(self.hearts))
self.pingstream.send(asbytes(str(self.lifetime))) self.pingstream.send(asbytes(str(self.lifetime)))
# flush stream to force immediate socket send
self.pingstream.flush()


def handle_new_heart(self, heart): def handle_new_heart(self, heart):
if self._new_handlers: if self._new_handlers:
Expand Down

0 comments on commit 1487f2f

Please sign in to comment.