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