david-collett / reclaimenergy

Home Assistant integration for Reclaim Energy heat pump hot water systems
20 stars 2 forks source link

Blocking call inside event loop #2

Open JP-Ellis opened 1 month ago

JP-Ellis commented 1 month ago

Thanks for the integration! Just wanted to report that I am getting the following warning from Home Assistant

Detected blocking call to load_cert_chain inside the event loop ```log 2024-09-29 10:19:16.101 WARNING (MainThread) [homeassistant.util.loop] Detected blocking call to load_cert_chain with args (, '/var/lib/hass/reclaimenergy/reclaim_cert.pem', '/var/lib/hass/reclaimenergy/reclaim_key.pem', None) inside the event loop by custom integration 'reclaimenergy' at custom_components/reclaimenergy/reclaimv2.py, line 206: async with aiomqtt.Client( (offender: /var/lib/private/hass/.venv/lib/python3.12/site-packages/paho/mqtt/client.py, line 796: context.load_cert_chain(certfile, keyfile, keyfile_password)), please create a bug report at https://github.com/david-collett/reclaimenergy/issues For developers, please see https://developers.home-assistant.io/docs/asyncio_blocking_operations/#load_cert_chain Traceback (most recent call last): File "/var/lib/hass/.venv/bin/hass", line 8, in sys.exit(main()) File "/var/lib/private/hass/.venv/lib/python3.12/site-packages/homeassistant/__main__.py", line 209, in main exit_code = runner.run(runtime_conf) File "/var/lib/private/hass/.venv/lib/python3.12/site-packages/homeassistant/runner.py", line 189, in run return loop.run_until_complete(setup_and_run_hass(runtime_config)) File "/usr/lib/python3.12/asyncio/base_events.py", line 674, in run_until_complete self.run_forever() File "/usr/lib/python3.12/asyncio/base_events.py", line 641, in run_forever self._run_once() File "/usr/lib/python3.12/asyncio/base_events.py", line 1986, in _run_once handle._run() File "/usr/lib/python3.12/asyncio/events.py", line 88, in _run self._context.run(self._callback, *self._args) File "/var/lib/hass/custom_components/reclaimenergy/reclaimv2.py", line 206, in _listen async with aiomqtt.Client( 2024-09-29 10:19:16.103 WARNING (MainThread) [homeassistant.util.loop] Detected blocking call to load_verify_locations with args (, '/var/lib/hass/reclaimenergy/AmazonRootCA1.pem') inside the event loop by custom integration 'reclaimenergy' at custom_components/reclaimenergy/reclaimv2.py, line 206: async with aiomqtt.Client( (offender: /var/lib/private/hass/.venv/lib/python3.12/site-packages/paho/mqtt/client.py, line 804: context.load_verify_locations(ca_certs)), please create a bug report at https://github.com/david-collett/reclaimenergy/issues For developers, please see https://developers.home-assistant.io/docs/asyncio_blocking_operations/#load_verify_locations Traceback (most recent call last): File "/var/lib/hass/.venv/bin/hass", line 8, in sys.exit(main()) File "/var/lib/private/hass/.venv/lib/python3.12/site-packages/homeassistant/__main__.py", line 209, in main exit_code = runner.run(runtime_conf) File "/var/lib/private/hass/.venv/lib/python3.12/site-packages/homeassistant/runner.py", line 189, in run return loop.run_until_complete(setup_and_run_hass(runtime_config)) File "/usr/lib/python3.12/asyncio/base_events.py", line 674, in run_until_complete self.run_forever() File "/usr/lib/python3.12/asyncio/base_events.py", line 641, in run_forever self._run_once() File "/usr/lib/python3.12/asyncio/base_events.py", line 1986, in _run_once handle._run() File "/usr/lib/python3.12/asyncio/events.py", line 88, in _run self._context.run(self._callback, *self._args) File "/var/lib/hass/custom_components/reclaimenergy/reclaimv2.py", line 206, in _listen async with aiomqtt.Client( ```

I suspect that aiomqtt.Client internally does these blocking calls, but it might be able to use Home Assistant's utilities.

Depending how you want to proceed, I could take a look and see if I can resolve it?

david-collett commented 1 month ago

Thanks for reporting this. Happy for you to take a look if you can. I won't be able to for a couple of weeks unfortunately.