##// END OF EJS Templates
handle undefined or closed zmq_stream in on_message...
MinRK -
Show More
@@ -84,6 +84,9 b' class KernelActionHandler(IPythonHandler):'
84
84
85 class ZMQChannelHandler(AuthenticatedZMQStreamHandler):
85 class ZMQChannelHandler(AuthenticatedZMQStreamHandler):
86
86
87 def __repr__(self):
88 return "%s(%s)" % (self.__class__.__name__, getattr(self, 'kernel_id', 'uninitialized'))
89
87 def create_stream(self):
90 def create_stream(self):
88 km = self.kernel_manager
91 km = self.kernel_manager
89 meth = getattr(km, 'connect_%s' % self.channel)
92 meth = getattr(km, 'connect_%s' % self.channel)
@@ -145,6 +148,12 b' class ZMQChannelHandler(AuthenticatedZMQStreamHandler):'
145 self.zmq_stream.on_recv(self._on_zmq_reply)
148 self.zmq_stream.on_recv(self._on_zmq_reply)
146
149
147 def on_message(self, msg):
150 def on_message(self, msg):
151 if self.zmq_stream is None:
152 return
153 elif self.zmq_stream.closed():
154 self.log.info("%s closed, closing websocket.", self)
155 self.close()
156 return
148 msg = json.loads(msg)
157 msg = json.loads(msg)
149 self.session.send(self.zmq_stream, msg)
158 self.session.send(self.zmq_stream, msg)
150
159
General Comments 0
You need to be logged in to leave comments. Login now