##// END OF EJS Templates
add first_beat delay to notebook heartbeats...
MinRK -
Show More
@@ -18,6 +18,7 b' Authors:'
18
18
19 import logging
19 import logging
20 import Cookie
20 import Cookie
21 import time
21 import uuid
22 import uuid
22
23
23 from tornado import web
24 from tornado import web
@@ -412,6 +413,7 b' class IOPubHandler(AuthenticatedZMQStreamHandler):'
412 return
413 return
413 km = self.application.kernel_manager
414 km = self.application.kernel_manager
414 self.time_to_dead = km.time_to_dead
415 self.time_to_dead = km.time_to_dead
416 self.first_beat = km.first_beat
415 kernel_id = self.kernel_id
417 kernel_id = self.kernel_id
416 try:
418 try:
417 self.iopub_stream = km.create_iopub_stream(kernel_id)
419 self.iopub_stream = km.create_iopub_stream(kernel_id)
@@ -446,6 +448,7 b' class IOPubHandler(AuthenticatedZMQStreamHandler):'
446 self._kernel_alive = True
448 self._kernel_alive = True
447
449
448 def ping_or_dead():
450 def ping_or_dead():
451 self.hb_stream.flush()
449 if self._kernel_alive:
452 if self._kernel_alive:
450 self._kernel_alive = False
453 self._kernel_alive = False
451 self.hb_stream.send(b'ping')
454 self.hb_stream.send(b'ping')
@@ -461,8 +464,9 b' class IOPubHandler(AuthenticatedZMQStreamHandler):'
461 self._kernel_alive = True
464 self._kernel_alive = True
462
465
463 self.hb_stream.on_recv(beat_received)
466 self.hb_stream.on_recv(beat_received)
464 self._hb_periodic_callback = ioloop.PeriodicCallback(ping_or_dead, self.time_to_dead*1000)
467 loop = ioloop.IOLoop.instance()
465 self._hb_periodic_callback.start()
468 self._hb_periodic_callback = ioloop.PeriodicCallback(ping_or_dead, self.time_to_dead*1000, loop)
469 loop.add_timeout(time.time()+self.first_beat, self._hb_periodic_callback.start)
466 self._beating= True
470 self._beating= True
467
471
468 def stop_hb(self):
472 def stop_hb(self):
@@ -195,7 +195,10 b' class MappingKernelManager(MultiKernelManager):'
195
195
196 kernel_argv = List(Unicode)
196 kernel_argv = List(Unicode)
197 kernel_manager = Instance(KernelManager)
197 kernel_manager = Instance(KernelManager)
198
198 time_to_dead = Float(3.0, config=True, help="""Kernel heartbeat interval in seconds.""")
199 time_to_dead = Float(3.0, config=True, help="""Kernel heartbeat interval in seconds.""")
200 first_beat = Float(5.0, config=True, help="Delay (in seconds) before sending first heartbeat.")
201
199 max_msg_size = Integer(65536, config=True, help="""
202 max_msg_size = Integer(65536, config=True, help="""
200 The max raw message size accepted from the browser
203 The max raw message size accepted from the browser
201 over a WebSocket connection.
204 over a WebSocket connection.
General Comments 0
You need to be logged in to leave comments. Login now