-
-
Notifications
You must be signed in to change notification settings - Fork 37
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
Create event loop only when necessary #58
Conversation
Reporting back from the HA issue:
As you suspected, still doesn't work. |
So I asked about this from homeassistant developers, and they mentioned that the are patching bleak internally which is why this approach won't work. Two potential solutions were offered: use the homeassistant-provided Both of these will require some not so light refactoring, so it might be just easier to create a separate asyncio thermostat interface for homeassistant to use (#59). |
I'll merge this as it is, afaik, the correct thing to do even if it doesn't fix the homeassistant issue it was aimed to fix. |
Calling
new_event_loop()
created a second event loop on python <3.10, andasyncio.wait_for()
created a task on the wrong loop, apparently.This PR checks if a loop exists already, and creates one only if none is available. Tested to work both using the dockerfile in the linked issue, and when it gets used by homeassistant.
Fixes #57