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

Better handle peripheral device exceptions #5

Open
tomcur opened this issue Sep 8, 2020 · 1 comment
Open

Better handle peripheral device exceptions #5

tomcur opened this issue Sep 8, 2020 · 1 comment
Milestone

Comments

@tomcur
Copy link
Member

tomcur commented Sep 8, 2020

It is expected of peripheral devices that they sometimes behave unpredictably. For example, hardware issues (loose connectors, timing issues) can cause problems with communication. This can lead to a variety of exceptions.

Currently, any such exception stops the program, even though other peripherals might still be working as expected. This can be troublesome especially for kits that are controlling actuators such as lights or climate control, as the control process also stops.

There are multiple ways to implement handling of such exceptions. For example:

  1. the program could indiscriminately catch any Exception (which does not include e.g. KeyboardInterrupt and SystemExit); or
  2. a PeripheralDeviceException could be created, with peripheral device code being required to catch exceptions to rethrow as PeripheralDeviceException.

The first alternative works in most cases, but has the con of potentially catching too many exceptions (but which would we not want to catch?). The second alternative is likely to sometimes still fail for some unforeseen exceptions.

Once an exception has been caught for a peripheral device, for now we might simply ignore that device. In the future, an attempt at recovering the device might be implemented.

@tomcur
Copy link
Member Author

tomcur commented Sep 8, 2020

Note that even though the program currently stops on exceptions, when using the official distributed kit images, the program is automatically restarted by systemd. However, due to #4, on some configurations the program can only be restarted so many times on a single boot before system resources run out.

@tomcur tomcur added this to the 1.0.0 milestone Oct 30, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant