hardbyte / hardbyte/python-can

Graceful exception handling in Notifier thread

Open
#907 7 comments 0 reactions 0 assignees View on GitHub
backend:iscan bug
Dominant language
Python
Stars
1.6k
Forks
697
PR merge metrics
No merged PRs in 30d

Description

The notifier module does not handle exceptions well. Some drivers (in this case) throw an exception if there is no other participant on the bus yet (messages are not ACKed) which effectively kills the listener thread of the Notifier class. If asyncio is used (loop=valid object) this leads to a gap and possible messages are lost.

A list of errors to be suppressed should be added to the Notifier class, enabling the user to disable certain errors. Alternatively, (at least) the iscan module needs to be rewritten not to forward any errors.

The following workaround is in place here:

```
class Notifier(can.Notifier):
def _rx_thread(self, bus):
while self._running:
try:
super()._rx_thread(bus)
except can.interfaces.iscan.IscanError:
pass
```

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.