Show More
@@ -103,8 +103,8 b' class ZMQChannelHandler(AuthenticatedZMQStreamHandler):' | |||||
103 | km = self.kernel_manager |
|
103 | km = self.kernel_manager | |
104 | kernel = km.get_kernel(self.kernel_id) |
|
104 | kernel = km.get_kernel(self.kernel_id) | |
105 | try: |
|
105 | try: | |
106 |
# check for |
|
106 | # check for previous request | |
107 |
|
|
107 | future = kernel._kernel_info_future | |
108 | except AttributeError: |
|
108 | except AttributeError: | |
109 | self.log.debug("Requesting kernel info from %s", self.kernel_id) |
|
109 | self.log.debug("Requesting kernel info from %s", self.kernel_id) | |
110 | # Create a kernel_info channel to query the kernel protocol version. |
|
110 | # Create a kernel_info channel to query the kernel protocol version. | |
@@ -113,9 +113,12 b' class ZMQChannelHandler(AuthenticatedZMQStreamHandler):' | |||||
113 | self.kernel_info_channel = km.connect_shell(self.kernel_id) |
|
113 | self.kernel_info_channel = km.connect_shell(self.kernel_id) | |
114 | self.kernel_info_channel.on_recv(self._handle_kernel_info_reply) |
|
114 | self.kernel_info_channel.on_recv(self._handle_kernel_info_reply) | |
115 | self.session.send(self.kernel_info_channel, "kernel_info_request") |
|
115 | self.session.send(self.kernel_info_channel, "kernel_info_request") | |
|
116 | # store the future on the kernel, so only one request is sent | |||
|
117 | kernel._kernel_info_future = self._kernel_info_future | |||
116 | else: |
|
118 | else: | |
117 | # use cached value, don't resend request |
|
119 | if not future.done(): | |
118 | self._finish_kernel_info(kernel_info) |
|
120 | self.log.debug("Waiting for pending kernel_info request") | |
|
121 | future.add_done_callback(lambda f: self._finish_kernel_info(f.result())) | |||
119 | return self._kernel_info_future |
|
122 | return self._kernel_info_future | |
120 |
|
123 | |||
121 | def _handle_kernel_info_reply(self, msg): |
|
124 | def _handle_kernel_info_reply(self, msg): | |
@@ -128,16 +131,14 b' class ZMQChannelHandler(AuthenticatedZMQStreamHandler):' | |||||
128 | msg = self.session.deserialize(msg) |
|
131 | msg = self.session.deserialize(msg) | |
129 | except: |
|
132 | except: | |
130 | self.log.error("Bad kernel_info reply", exc_info=True) |
|
133 | self.log.error("Bad kernel_info reply", exc_info=True) | |
131 |
self._kernel_info_future.set_result( |
|
134 | self._kernel_info_future.set_result({}) | |
132 | return |
|
135 | return | |
133 | else: |
|
136 | else: | |
134 | info = msg['content'] |
|
137 | info = msg['content'] | |
135 | self.log.debug("Received kernel info: %s", info) |
|
138 | self.log.debug("Received kernel info: %s", info) | |
136 | if msg['msg_type'] != 'kernel_info_reply' or 'protocol_version' not in info: |
|
139 | if msg['msg_type'] != 'kernel_info_reply' or 'protocol_version' not in info: | |
137 | self.log.error("Kernel info request failed, assuming current %s", info) |
|
140 | self.log.error("Kernel info request failed, assuming current %s", info) | |
138 | else: |
|
141 | info = {} | |
139 | kernel = self.kernel_manager.get_kernel(self.kernel_id) |
|
|||
140 | kernel._kernel_info = info |
|
|||
141 | self._finish_kernel_info(info) |
|
142 | self._finish_kernel_info(info) | |
142 |
|
143 | |||
143 | # close the kernel_info channel, we don't need it anymore |
|
144 | # close the kernel_info channel, we don't need it anymore | |
@@ -179,7 +180,7 b' class ZMQChannelHandler(AuthenticatedZMQStreamHandler):' | |||||
179 | if future.done(): |
|
180 | if future.done(): | |
180 | return |
|
181 | return | |
181 | self.log.warn("Timeout waiting for kernel_info reply from %s", self.kernel_id) |
|
182 | self.log.warn("Timeout waiting for kernel_info reply from %s", self.kernel_id) | |
182 |
future.set_result( |
|
183 | future.set_result({}) | |
183 | loop = IOLoop.current() |
|
184 | loop = IOLoop.current() | |
184 | loop.add_timeout(loop.time() + self.kernel_info_timeout, give_up) |
|
185 | loop.add_timeout(loop.time() + self.kernel_info_timeout, give_up) | |
185 | # actually wait for it |
|
186 | # actually wait for it |
General Comments 0
You need to be logged in to leave comments.
Login now