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

Invert default value logic for BusABC._is_shutdown #1774

Merged
merged 1 commit into from Apr 29, 2024

Conversation

acolomb
Copy link
Contributor

@acolomb acolomb commented Apr 25, 2024

The destructor of BusABC gives a warning when shutdown() was not previously called on the object after construction. However, if the construction fails (e.g. when the derived bus class constructor raises an exception), there is no way to call shutdown() on the unfinished object, and it is not necessary either.

Initialize the _is_shutdown flag to False initially and flip it to True only when the parent class constructor runs, which usually happens last in derived classes. That avoids the shutdown warning for objects that failed to initialize at all.

This is an alternative approach solving the same problem as #1771, but that PR could be merged independently to have an error log message before raising the constructor exception.

The destructor of BusABC gives a warning when shutdown() was not
previously called on the object after construction.  However, if the
construction fails (e.g. when the derived bus class constructor raises
an exception), there is no way to call shutdown() on the unfinished
object, and it is not necessary either.

Initialize the _is_shutdown flag to False initially and flip it to
True only when the parent class constructor runs, which usually
happens last in derived classes.  That avoids the shutdown warning for
objects that failed to initialize at all.
Copy link
Owner

@hardbyte hardbyte left a comment

Choose a reason for hiding this comment

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

Thanks - seems very reasonable.

@hardbyte hardbyte merged commit 32c7640 into hardbyte:main Apr 29, 2024
30 checks passed
@acolomb acolomb deleted the bus-init-is-shutdown branch April 30, 2024 13:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants