Show More
@@ -137,7 +137,23 b' class ZMQSocketChannel(Thread):' | |||||
137 | terminates. :class:`RuntimeError` will be raised if |
|
137 | terminates. :class:`RuntimeError` will be raised if | |
138 | :meth:`~threading.Thread.start` is called again. |
|
138 | :meth:`~threading.Thread.start` is called again. | |
139 | """ |
|
139 | """ | |
|
140 | if self.ioloop is not None: | |||
|
141 | self.ioloop.stop() | |||
140 | self.join() |
|
142 | self.join() | |
|
143 | self.close() | |||
|
144 | ||||
|
145 | def close(self): | |||
|
146 | if self.ioloop is not None: | |||
|
147 | try: | |||
|
148 | self.ioloop.close(all_fds=True) | |||
|
149 | except Exception: | |||
|
150 | pass | |||
|
151 | if self.socket is not None: | |||
|
152 | try: | |||
|
153 | self.socket.close(linger=0) | |||
|
154 | except Exception: | |||
|
155 | pass | |||
|
156 | self.socket = None | |||
141 |
|
157 | |||
142 | @property |
|
158 | @property | |
143 | def address(self): |
|
159 | def address(self): | |
@@ -198,15 +214,6 b' class ShellChannel(ZMQSocketChannel):' | |||||
198 | self.stream = zmqstream.ZMQStream(self.socket, self.ioloop) |
|
214 | self.stream = zmqstream.ZMQStream(self.socket, self.ioloop) | |
199 | self.stream.on_recv(self._handle_recv) |
|
215 | self.stream.on_recv(self._handle_recv) | |
200 | self._run_loop() |
|
216 | self._run_loop() | |
201 | try: |
|
|||
202 | self.socket.close() |
|
|||
203 | except: |
|
|||
204 | pass |
|
|||
205 |
|
||||
206 | def stop(self): |
|
|||
207 | """Stop the channel's event loop and join its thread.""" |
|
|||
208 | self.ioloop.stop() |
|
|||
209 | super(ShellChannel, self).stop() |
|
|||
210 |
|
217 | |||
211 | def call_handlers(self, msg): |
|
218 | def call_handlers(self, msg): | |
212 | """This method is called in the ioloop thread when a message arrives. |
|
219 | """This method is called in the ioloop thread when a message arrives. | |
@@ -407,15 +414,6 b' class IOPubChannel(ZMQSocketChannel):' | |||||
407 | self.stream = zmqstream.ZMQStream(self.socket, self.ioloop) |
|
414 | self.stream = zmqstream.ZMQStream(self.socket, self.ioloop) | |
408 | self.stream.on_recv(self._handle_recv) |
|
415 | self.stream.on_recv(self._handle_recv) | |
409 | self._run_loop() |
|
416 | self._run_loop() | |
410 | try: |
|
|||
411 | self.socket.close() |
|
|||
412 | except: |
|
|||
413 | pass |
|
|||
414 |
|
||||
415 | def stop(self): |
|
|||
416 | """Stop the channel's event loop and join its thread.""" |
|
|||
417 | self.ioloop.stop() |
|
|||
418 | super(IOPubChannel, self).stop() |
|
|||
419 |
|
417 | |||
420 | def call_handlers(self, msg): |
|
418 | def call_handlers(self, msg): | |
421 | """This method is called in the ioloop thread when a message arrives. |
|
419 | """This method is called in the ioloop thread when a message arrives. | |
@@ -475,15 +473,6 b' class StdInChannel(ZMQSocketChannel):' | |||||
475 | self.stream = zmqstream.ZMQStream(self.socket, self.ioloop) |
|
473 | self.stream = zmqstream.ZMQStream(self.socket, self.ioloop) | |
476 | self.stream.on_recv(self._handle_recv) |
|
474 | self.stream.on_recv(self._handle_recv) | |
477 | self._run_loop() |
|
475 | self._run_loop() | |
478 | try: |
|
|||
479 | self.socket.close() |
|
|||
480 | except: |
|
|||
481 | pass |
|
|||
482 |
|
||||
483 | def stop(self): |
|
|||
484 | """Stop the channel's event loop and join its thread.""" |
|
|||
485 | self.ioloop.stop() |
|
|||
486 | super(StdInChannel, self).stop() |
|
|||
487 |
|
476 | |||
488 | def call_handlers(self, msg): |
|
477 | def call_handlers(self, msg): | |
489 | """This method is called in the ioloop thread when a message arrives. |
|
478 | """This method is called in the ioloop thread when a message arrives. | |
@@ -603,10 +592,6 b' class HBChannel(ZMQSocketChannel):' | |||||
603 | # and close/reopen the socket, because the REQ/REP cycle has been broken |
|
592 | # and close/reopen the socket, because the REQ/REP cycle has been broken | |
604 | self._create_socket() |
|
593 | self._create_socket() | |
605 | continue |
|
594 | continue | |
606 | try: |
|
|||
607 | self.socket.close() |
|
|||
608 | except: |
|
|||
609 | pass |
|
|||
610 |
|
595 | |||
611 | def pause(self): |
|
596 | def pause(self): | |
612 | """Pause the heartbeat.""" |
|
597 | """Pause the heartbeat.""" |
@@ -246,11 +246,7 b' class KernelManager(LoggingConfigurable, ConnectionFileMixin):' | |||||
246 | self.stop_restarter() |
|
246 | self.stop_restarter() | |
247 |
|
247 | |||
248 | # FIXME: Shutdown does not work on Windows due to ZMQ errors! |
|
248 | # FIXME: Shutdown does not work on Windows due to ZMQ errors! | |
249 | if sys.platform == 'win32': |
|
249 | if now or sys.platform == 'win32': | |
250 | self._kill_kernel() |
|
|||
251 | return |
|
|||
252 |
|
||||
253 | if now: |
|
|||
254 | if self.has_kernel: |
|
250 | if self.has_kernel: | |
255 | self._kill_kernel() |
|
251 | self._kill_kernel() | |
256 | else: |
|
252 | else: | |
@@ -273,6 +269,8 b' class KernelManager(LoggingConfigurable, ConnectionFileMixin):' | |||||
273 | self.cleanup_ipc_files() |
|
269 | self.cleanup_ipc_files() | |
274 | else: |
|
270 | else: | |
275 | self.cleanup_ipc_files() |
|
271 | self.cleanup_ipc_files() | |
|
272 | ||||
|
273 | self._close_control_socket() | |||
276 |
|
274 | |||
277 | def restart_kernel(self, now=False, **kw): |
|
275 | def restart_kernel(self, now=False, **kw): | |
278 | """Restarts a kernel with the arguments that were used to launch it. |
|
276 | """Restarts a kernel with the arguments that were used to launch it. |
General Comments 0
You need to be logged in to leave comments.
Login now