##// END OF EJS Templates
Removing last remnant of heartbeat from IOPubHandler.
Brian E. Granger -
Show More
@@ -467,8 +467,6 b' class IOPubHandler(AuthenticatedZMQStreamHandler):'
467
467
468 def initialize(self, *args, **kwargs):
468 def initialize(self, *args, **kwargs):
469 self.iopub_stream = None
469 self.iopub_stream = None
470 self.hb_stream = None
471 self.heartbeat = None
472
470
473 def on_first_message(self, msg):
471 def on_first_message(self, msg):
474 try:
472 try:
@@ -480,10 +478,6 b' class IOPubHandler(AuthenticatedZMQStreamHandler):'
480 kernel_id = self.kernel_id
478 kernel_id = self.kernel_id
481 try:
479 try:
482 self.iopub_stream = km.create_iopub_stream(kernel_id)
480 self.iopub_stream = km.create_iopub_stream(kernel_id)
483 self.hb_stream = km.create_hb_stream(kernel_id)
484 self.heartbeat = Heartbeat(
485 stream=self.hb_stream, config=self.application.config
486 )
487 except web.HTTPError:
481 except web.HTTPError:
488 # WebSockets don't response to traditional error codes so we
482 # WebSockets don't response to traditional error codes so we
489 # close the connection.
483 # close the connection.
@@ -492,7 +486,6 b' class IOPubHandler(AuthenticatedZMQStreamHandler):'
492 self.close()
486 self.close()
493 else:
487 else:
494 self.iopub_stream.on_recv(self._on_zmq_reply)
488 self.iopub_stream.on_recv(self._on_zmq_reply)
495 self.heartbeat.start(self.kernel_died)
496
489
497 def on_message(self, msg):
490 def on_message(self, msg):
498 pass
491 pass
@@ -501,28 +494,9 b' class IOPubHandler(AuthenticatedZMQStreamHandler):'
501 # This method can be called twice, once by self.kernel_died and once
494 # This method can be called twice, once by self.kernel_died and once
502 # from the WebSocket close event. If the WebSocket connection is
495 # from the WebSocket close event. If the WebSocket connection is
503 # closed before the ZMQ streams are setup, they could be None.
496 # closed before the ZMQ streams are setup, they could be None.
504 self.stop_hb()
505 if self.iopub_stream is not None and not self.iopub_stream.closed():
497 if self.iopub_stream is not None and not self.iopub_stream.closed():
506 self.iopub_stream.on_recv(None)
498 self.iopub_stream.on_recv(None)
507 self.iopub_stream.close()
499 self.iopub_stream.close()
508 if self.hb_stream is not None and not self.hb_stream.closed():
509 self.hb_stream.close()
510 # stop the heartbeat here
511
512 def _delete_kernel_data(self):
513 """Remove the kernel data and notebook mapping."""
514 self.application.kernel_manager.delete_mapping_for_kernel(self.kernel_id)
515
516 def kernel_died(self):
517 self._delete_kernel_data()
518 self.application.log.error("Kernel died: %s" % self.kernel_id)
519 self.write_message(
520 {'header': {'msg_type': 'status'},
521 'parent_header': {},
522 'content': {'execution_state':'dead'}
523 }
524 )
525 self.on_close()
526
500
527
501
528 class ShellHandler(AuthenticatedZMQStreamHandler):
502 class ShellHandler(AuthenticatedZMQStreamHandler):
General Comments 0
You need to be logged in to leave comments. Login now