Show More
@@ -94,11 +94,23 b" if os.environ.get('IPYTHON_ALLOW_DRAFT_WEBSOCKETS_FOR_PHANTOMJS', False):" | |||
|
94 | 94 | |
|
95 | 95 | class ZMQStreamHandler(WebSocketHandler): |
|
96 | 96 | |
|
97 | if tornado.version_info < (4,1): | |
|
98 | """Backport send_error from tornado 4.1 to 4.0""" | |
|
99 | def send_error(self, *args, **kwargs): | |
|
100 | if self.stream is None: | |
|
101 | super(WebSocketHandler, self).send_error(*args, **kwargs) | |
|
102 | else: | |
|
103 | # If we get an uncaught exception during the handshake, | |
|
104 | # we have no choice but to abruptly close the connection. | |
|
105 | # TODO: for uncaught exceptions after the handshake, | |
|
106 | # we can close the connection more gracefully. | |
|
107 | self.stream.close() | |
|
108 | ||
|
109 | ||
|
97 | 110 | def check_origin(self, origin): |
|
98 | 111 | """Check Origin == Host or Access-Control-Allow-Origin. |
|
99 | 112 | |
|
100 | 113 | Tornado >= 4 calls this method automatically, raising 403 if it returns False. |
|
101 | We call it explicitly in `open` on Tornado < 4. | |
|
102 | 114 | """ |
|
103 | 115 | if self.allow_origin == '*': |
|
104 | 116 | return True |
@@ -160,7 +172,10 b' class ZMQStreamHandler(WebSocketHandler):' | |||
|
160 | 172 | def _on_zmq_reply(self, stream, msg_list): |
|
161 | 173 | # Sometimes this gets triggered when the on_close method is scheduled in the |
|
162 | 174 | # eventloop but hasn't been called. |
|
163 |
if stream.closed(): |
|
|
175 | if self.stream.closed() or stream.closed(): | |
|
176 | self.log.warn("zmq message arrived on closed channel") | |
|
177 | self.close() | |
|
178 | return | |
|
164 | 179 | channel = getattr(stream, 'channel', None) |
|
165 | 180 | try: |
|
166 | 181 | msg = self._reserialize_reply(msg_list, channel=channel) |
General Comments 0
You need to be logged in to leave comments.
Login now