Skip to content

Invert default value logic for BusABC._is_shutdown #1774

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

Merged
merged 1 commit into from
Apr 29, 2024
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
7 changes: 6 additions & 1 deletion can/bus.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,8 @@ class BusABC(metaclass=ABCMeta):
#: Log level for received messages
RECV_LOGGING_LEVEL = 9

_is_shutdown: bool = False
#: Assume that no cleanup is needed until something was initialized
_is_shutdown: bool = True
_can_protocol: CanProtocol = CanProtocol.CAN_20

@abstractmethod
Expand Down Expand Up @@ -97,6 +98,10 @@ def __init__(
"""
self._periodic_tasks: List[_SelfRemovingCyclicTask] = []
self.set_filters(can_filters)
# Flip the class default value when the constructor finishes. That
# usually means the derived class constructor was also successful,
# since it calls this parent constructor last.
self._is_shutdown: bool = False

def __str__(self) -> str:
return self.channel_info
Expand Down
Loading