GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Invert default value logic for BusABC._is_shutdown by acolomb · Pull Request #1774 · hardbyte/python-can

Conversation

@acolomb

@acolomb acolomb commented Apr 25, 2024

Copy link
Copy Markdown
Contributor

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.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@acolomb
Invert default value logic for BusABC._is_shutdown.
916b151
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.
@acolomb acolomb mentioned this pull request Apr 25, 2024
Gracefully handle errors when binding SocketCAN fails #1771
Merged
hardbyte
hardbyte approved these changes Apr 29, 2024
View reviewed changes

@hardbyte hardbyte left a comment

Copy link
Copy Markdown
Owner

There was a problem hiding this 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.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@hardbyte
hardbyte merged commit 32c7640 into hardbyte:main Apr 29, 2024
@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

Reviewers

@hardbyte hardbyte hardbyte approved these changes

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Uh oh!

There was an error while loading. Please reload this page.

2 participants

@acolomb @hardbyte
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.