Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Check that channels exist before asking if they are alive #785

Merged
merged 1 commit into from
May 8, 2022
Merged
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
10 changes: 5 additions & 5 deletions jupyter_client/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -337,11 +337,11 @@ def stop_channels(self) -> None:
def channels_running(self) -> bool:
"""Are any of the channels created and running?"""
return (
self.shell_channel.is_alive()
or self.iopub_channel.is_alive()
or self.stdin_channel.is_alive()
or self.hb_channel.is_alive()
or self.control_channel.is_alive()
(self._shell_channel and self.shell_channel.is_alive())
or (self._iopub_channel and self.iopub_channel.is_alive())
or (self._stdin_channel and self.stdin_channel.is_alive())
or (self._hb_channel and self.hb_channel.is_alive())
or (self._control_channel and self.control_channel.is_alive())
Comment on lines +340 to +344
Copy link
Member

Choose a reason for hiding this comment

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

These changes seem more in line with the docstring "Are any of the channels created and running?", e.g. with only self.shell_channel.is_alive() we are creating a shell channel if it doesn't already exists, so we are only checking if it is running.
Your changes ensure that a channel already exists before checking if it is running, which seems like the right thing to do IMO.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks @davidbrochart!

)

ioloop = None # Overridden in subclasses that use pyzmq event loop
Expand Down