maorcc / citymind_water_meter

Home Assistant Integration with cp.city-mind.com, an Israeli water meters reading service
Apache License 2.0
40 stars 2 forks source link

Move to async methods #61

Closed GuyKh closed 4 months ago

GuyKh commented 4 months ago

As written in the logs:

2024-05-07 11:18:04.469 ERROR (MainThread) [homeassistant] Error doing job: Future exception was never retrieved
Traceback (most recent call last):
  File "/usr/local/lib/python3.12/concurrent/futures/thread.py", line 58, in run
    result = self.fn(*self.args, **self.kwargs)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/config/custom_components/citymind_water_meter/core/managers/home_assistant.py", line 183, in _update_data_providers
    self._hass.async_create_task(self.async_update_data_providers())
  File "/usr/src/homeassistant/homeassistant/core.py", line 816, in async_create_task
    self.verify_event_loop_thread("async_create_task")
  File "/usr/src/homeassistant/homeassistant/core.py", line 440, in verify_event_loop_thread
    frame.report(
  File "/usr/src/homeassistant/homeassistant/helpers/frame.py", line 162, in report
    _report_integration(what, integration_frame, level, error_if_integration)
  File "/usr/src/homeassistant/homeassistant/helpers/frame.py", line 203, in _report_integration
    raise RuntimeError(
RuntimeError: Detected that custom integration 'citymind_water_meter' calls async_create_task from a thread at custom_components/citymind_water_meter/core/managers/home_assistant.py, line 183: self._hass.async_create_task(self.async_update_data_providers()). Please report it to the author of the 'citymind_water_meter' custom integration.

calls to async_create_task are not being awaited. Should make all the functions async-await.

elad-bar commented 4 months ago

Which version of integration are you using?

GuyKh commented 4 months ago

@elad-bar - the latest - 2.0.12. But also looking at the code - the async calls are done synchroneously example example example example

elad-bar commented 4 months ago

Latest is 2.0.14 and it fixes that issue, pls check and update

Thanks

GuyKh commented 4 months ago

Thanks @elad-bar - it seems that HACS didn't update the latest.

elad-bar commented 4 months ago

Great... happens to HACS sometimes :)