Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 12 additions & 3 deletions ipykernel/control.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,16 @@ def __init__(self, **kwargs):
self.pydev_do_not_trace = True
self.is_pydev_daemon_thread = True

def run(self):
def run(self):
self.io_loop.make_current()
self.io_loop.start()
self.io_loop.close(all_fds=True)
try:
self.io_loop.start()
finally:
self.io_loop.close()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍


def stop(self):
"""Stop the thread.

This method is threadsafe.
"""
self.io_loop.add_callback(self.io_loop.stop)
6 changes: 5 additions & 1 deletion ipykernel/kernelapp.py
Original file line number Diff line number Diff line change
Expand Up @@ -346,6 +346,10 @@ def close(self):
self.log.debug("Closing iopub channel")
self.iopub_thread.stop()
self.iopub_thread.close()
if self.control_thread and self.control_thread.is_alive():
self.log.debug("Closing control thread")
self.control_thread.stop()
self.control_thread.join()

if self.debugpy_socket and not self.debugpy_socket.closed:
self.debugpy_socket.close()
Expand Down Expand Up @@ -487,7 +491,7 @@ def init_kernel(self):
control_stream=control_stream,
debugpy_stream=debugpy_stream,
debug_shell_socket=self.debug_shell_socket,
shell_stream=shell_stream,
shell_stream=shell_stream,
control_thread=self.control_thread,
iopub_thread=self.iopub_thread,
iopub_socket=self.iopub_socket,
Expand Down