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

Update camera.py #22

Closed
wants to merge 1 commit into from
Closed

Update camera.py #22

wants to merge 1 commit into from

Conversation

kk60503
Copy link
Contributor

@kk60503 kk60503 commented May 12, 2024

fix exception handling when camera isn't found so program does not crash

fix exception handling when camera isn't found so program does not crash
Copy link
Member

@ryanpdx ryanpdx left a comment

Choose a reason for hiding this comment

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

An extra level of complexity is the kernel module wont be loaded until after ~20 seconds after boot as the PRUs must exist before the module is loaded.

This or the service that uses an object of this class will need to handle it the fact the camera will not be found at the start of the app, but should be found / accessible later on.

Also run black and isort to pass the workflow.

return value
with open(f"{context_path}/{name}", "r") as f:
value = int(f.read())
return value
Copy link
Member

Choose a reason for hiding this comment

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

don't return inside of a with block

Choose a reason for hiding this comment

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

Why not? It'll do the right thing, the resource will be cleaned up (the file closed) no matter how you leave the block, return included. Returning inside a with block is even called out in the relevant PEP as a reason why you'd want to use it.

@ryanpdx
Copy link
Member

ryanpdx commented May 26, 2024

Closing in favor of #23

@ryanpdx ryanpdx closed this May 26, 2024
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

3 participants