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

Thread safety: missing @callback decorator #110

Closed
bdraco opened this issue Apr 25, 2024 · 5 comments
Closed

Thread safety: missing @callback decorator #110

bdraco opened this issue Apr 25, 2024 · 5 comments

Comments

@bdraco
Copy link
Contributor

bdraco commented Apr 25, 2024

diff --git a/custom_components/hpprinter/managers/home_assistant.py b/custom_components/hpprinter/managers/home_assistant.py
index a690265..0da9894 100644
--- a/custom_components/hpprinter/managers/home_assistant.py
+++ b/custom_components/hpprinter/managers/home_assistant.py
@@ -9,7 +9,7 @@ import sys
 from typing import Optional
 
 from homeassistant.config_entries import ConfigEntry
-from homeassistant.core import HomeAssistant
+from homeassistant.core import callback, HomeAssistant
 from homeassistant.helpers.dispatcher import async_dispatcher_send
 from homeassistant.helpers.entity_registry import EntityRegistry, async_get
 from homeassistant.helpers.event import async_track_time_interval
@@ -42,6 +42,7 @@ class HPPrinterHomeAssistant:
 
         self._config_manager = ConfigManager()
 
+        @callback
         def update_entities(now):
             self._hass.async_create_task(self.async_update(now))
 

This function is missing an @callback decorator so it will be run in the executor when async_track_time_interval fires instead of the event loop

@elad-bar
Copy link
Owner

elad-bar commented May 7, 2024

beta version v2.0.0b7 fixes it, but it's not fully stablized yet

@elad-bar
Copy link
Owner

fixed in v2.0.0, please check and update if it works

thanks

@bdraco
Copy link
Contributor Author

bdraco commented Jun 15, 2024

I don't use this integration so I can't test, I was only helping out a user who was tracking down some instability in their HA instance.

@elad-bar
Copy link
Owner

Thsnks, closing

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