Show More
@@ -479,6 +479,8 b' class IOPubHandler(AuthenticatedZMQStreamHandler):' | |||
|
479 | 479 | return |
|
480 | 480 | km = self.application.kernel_manager |
|
481 | 481 | kernel_id = self.kernel_id |
|
482 | km.add_restart_callback(kernel_id, self.on_kernel_restarted) | |
|
483 | km.add_restart_callback(kernel_id, self.on_restart_failed, 'dead') | |
|
482 | 484 | try: |
|
483 | 485 | self.iopub_stream = km.connect_iopub(kernel_id) |
|
484 | 486 | except web.HTTPError: |
@@ -493,10 +495,31 b' class IOPubHandler(AuthenticatedZMQStreamHandler):' | |||
|
493 | 495 | def on_message(self, msg): |
|
494 | 496 | pass |
|
495 | 497 | |
|
498 | def _send_status_message(self, status): | |
|
499 | msg = self.session.msg("status", | |
|
500 | {'execution_state': status} | |
|
501 | ) | |
|
502 | self.write_message(jsonapi.dumps(msg, default=date_default)) | |
|
503 | ||
|
504 | def on_kernel_restarted(self): | |
|
505 | logging.warn("kernel %s restarted", self.kernel_id) | |
|
506 | self._send_status_message('restarting') | |
|
507 | ||
|
508 | def on_restart_failed(self): | |
|
509 | logging.error("kernel %s restarted failed!", self.kernel_id) | |
|
510 | self._send_status_message('dead') | |
|
511 | ||
|
496 | 512 | def on_close(self): |
|
497 | 513 | # This method can be called twice, once by self.kernel_died and once |
|
498 | 514 | # from the WebSocket close event. If the WebSocket connection is |
|
499 | 515 | # closed before the ZMQ streams are setup, they could be None. |
|
516 | km = self.application.kernel_manager | |
|
517 | km.remove_restart_callback( | |
|
518 | self.kernel_id, self.on_kernel_restarted, | |
|
519 | ) | |
|
520 | km.remove_restart_callback( | |
|
521 | self.kernel_id, self.on_restart_failed, 'dead', | |
|
522 | ) | |
|
500 | 523 | if self.iopub_stream is not None and not self.iopub_stream.closed(): |
|
501 | 524 | self.iopub_stream.on_recv(None) |
|
502 | 525 | self.iopub_stream.close() |
General Comments 0
You need to be logged in to leave comments.
Login now