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

Feature suggestion: Thread safety #10

Open
freol35241 opened this issue Aug 20, 2023 · 0 comments
Open

Feature suggestion: Thread safety #10

freol35241 opened this issue Aug 20, 2023 · 0 comments

Comments

@freol35241
Copy link

Currrently. the handling of the UDP sockets in pyduro is not thread safe. sending two Frames to the same burner from two different threads will result in an Address already in use error in on of them.

I resorted to explicitly using a threading.Lock in my application to work around this: https://github.com/freol35241/aduro2mqtt/blob/main/main.py#L51

It would however be nicer f this feature was offered internally as part of pyduro instead. One possible solution would be to encapsulate the socket in a thread safe BurnerConnection class (internally using a threading.Lock). An instance of this class can then be passed to any Frame.send call instead of the connection details. This has the added benefit of reusing the socket for multiple calls rather than creating a new one for every call to Frame.send.

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

1 participant