diff --git a/jupyter_client/client.py b/jupyter_client/client.py index 5ffa069d9..c70e30b70 100644 --- a/jupyter_client/client.py +++ b/jupyter_client/client.py @@ -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()) ) ioloop = None # Overridden in subclasses that use pyzmq event loop