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

Error handling makes it impossible to use as library #703

Open
broglep opened this issue Nov 3, 2024 · 2 comments
Open

Error handling makes it impossible to use as library #703

broglep opened this issue Nov 3, 2024 · 2 comments

Comments

@broglep
Copy link

broglep commented Nov 3, 2024

The current approach of calling sys.exit() when a failure happens makes it impossible to use the library as part of an other project (e.g. home assistant integration)

Workaround of monkey patching that method does also not fully work as then the code flow continues and does not abort.

Example:
https://github.com/meshtastic/python/blob/master/meshtastic/mesh_interface.py#L444

@ianmcorvidae
Copy link
Contributor

Yes, definitely agreed. I'm curious what you think of the proposed refactoring in the comments on #579 -- I believe that'd also make it easier to update these cases. I haven't been able to devote much time to this library for the last few months, but hopefully I can devote some time in the next couple weeks.

@broglep
Copy link
Author

broglep commented Dec 21, 2024

The general direction of #579 sound like a very needed improvement. There should be a clear split between mesh interface/connection/transport implementation and then the code that exposes this functionality as a cli (rendering)

Current situation of the library is pretty tangled, so much so that I didn't see a clear path on how to improve / work around it and I have made my own attempt at re-implementing parts of it: https://github.com/broglep/homeassistant-meshtastic/tree/dev/custom_components/meshtastic/aiomeshtastic

I also needed async support and focused on getting it working for long running connection, something that I didn't see in reach with the current code base & design decisions.

I found it actually quite hard to get a good abstractions and where to put what functionality, and the protobuf protocol itself is not helping, it is clearly visible that everything has grown organically. It would require quite some design work to build an interface/abstraction that abstract away all the messy detail of the protobuf protocol.

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

No branches or pull requests

2 participants