-
Notifications
You must be signed in to change notification settings - Fork 33
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
Detected blocking call to load_verify_locations with args (<ssl.SSLContext object at 0x70ff42e77dd0>,) #577
Comments
I got the same running on Pi4 Logger: homeassistant.util.loop Detected blocking call to load_verify_locations with args (<ssl.SSLContext object at 0x7f60de29d0>,) inside the event loop by custom integration 'myenergi' at custom_components/myenergi/init.py, line 55: await conn.discoverLocations() (offender: /usr/local/lib/python3.12/site-packages/httpx/_config.py, line 147: context.load_verify_locations(cafile=cafile)), please create a bug report at https://github.com/cjne/ha-myenergi/issues For developers, please see https://developers.home-assistant.io/docs/asyncio_blocking_operations/#load_verify_locations Traceback (most recent call last): File "", line 198, in _run_module_as_main File "", line 88, in _run_code File "/usr/src/homeassistant/homeassistant/main.py", line 223, in sys.exit(main()) File "/usr/src/homeassistant/homeassistant/main.py", line 209, in main exit_code = runner.run(runtime_conf) File "/usr/src/homeassistant/homeassistant/runner.py", line 189, in run return loop.run_until_complete(setup_and_run_hass(runtime_config)) File "/usr/local/lib/python3.12/asyncio/base_events.py", line 674, in run_until_complete self.run_forever() File "/usr/local/lib/python3.12/asyncio/base_events.py", line 641, in run_forever self._run_once() File "/usr/local/lib/python3.12/asyncio/base_events.py", line 1990, in _run_once handle._run() File "/usr/local/lib/python3.12/asyncio/events.py", line 88, in _run self._context.run(self._callback, *self._args) File "/usr/src/homeassistant/homeassistant/config_entries.py", line 752, in async_setup_locked await self.async_setup(hass, integration=integration) File "/usr/src/homeassistant/homeassistant/config_entries.py", line 604, in async_setup result = await component.async_setup_entry(hass, self) File "/config/custom_components/myenergi/init.py", line 55, in async_setup_entry await conn.discoverLocations() |
I haven't upgraded yet to see this error, but the fix looks simple enough. I'll try to bump my dev HA to the latest version and create a PR. |
Glad the fix looks simple enough, for me the best way to fix it is unclear yet :) I would say the issue is in pymyenergi. In Blocking operations with asyncio a few helpers are suggested, like |
Got the same today - if you need more logs or diagnostics let me know. |
I started looking at the issue, but the fix might not be that simple. In order to move the currently blocking operation out of the event loop, the suggestion from the HA devs is to use a httpx_client helper from the homeassistant library. Which ideally we want to avoid as the blocking call happens in pymyenergi, which shouldn't depend on homeassistant. I'll keep looking for other ways to solve this. |
So I thought I could simply change the code to:
however, this results in the following error:
Strange as the same approach (async_add_executor_job) works fine in other parts of code. |
Thanks for trying to figure this out! So i've made some changes, first i added a way for us to pass the httpx.AsyncClient we can get from HA to the pymyenergi Connection instance, and changed the http calls to re-user the client instead opening/closing the connection for each invokation. Then i modified the integration setup to get httpx.AsyncClient from the HA helper function and pass it to the pymyenergi Connection constructor. It all seems to work fine, the warning is gone :) |
Nice work @CJNE! |
Thank you! |
New version of HomeAssistant docker now throws this…
Detected blocking call to load_verify_locations with args (<ssl.SSLContext object at 0x70ff42e77dd0>,) inside the event loop by custom integration 'myenergi' at custom_components/myenergi/init.py, line 107: await self.client.refresh() (offender: /usr/local/lib/python3.12/site-packages/httpx/_config.py, line 147: context.load_verify_locations(cafile=cafile)), please create a bug report at https://github.com/cjne/ha-myenergi/issues For developers, please see https://developers.home-assistant.io/docs/asyncio_blocking_operations/#load_verify_locations Traceback (most recent call last): File "", line 198, in _run_module_as_main File "", line 88, in _run_code File "/usr/src/homeassistant/homeassistant/main.py", line 223, in sys.exit(main()) File "/usr/src/homeassistant/homeassistant/main.py", line 209, in main exit_code = runner.run(runtime_conf) File "/usr/src/homeassistant/homeassistant/runner.py", line 189, in run return loop.run_until_complete(setup_and_run_hass(runtime_config)) File "/usr/local/lib/python3.12/asyncio/base_events.py", line 674, in run_until_complete self.run_forever() File "/usr/local/lib/python3.12/asyncio/base_events.py", line 641, in run_forever self._run_once() File "/usr/local/lib/python3.12/asyncio/base_events.py", line 1990, in _run_once handle._run() File "/usr/local/lib/python3.12/asyncio/events.py", line 88, in _run self._context.run(self._callback, *self._args) File "/usr/src/homeassistant/homeassistant/config_entries.py", line 752, in async_setup_locked await self.async_setup(hass, integration=integration) File "/usr/src/homeassistant/homeassistant/config_entries.py", line 604, in async_setup result = await component.async_setup_entry(hass, self) File "/config/custom_components/myenergi/init.py", line 60, in async_setup_entry await coordinator.async_config_entry_first_refresh() File "/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py", line 281, in async_config_entry_first_refresh await self._async_refresh( File "/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py", line 354, in _async_refresh self.data = await self._async_update_data() File "/config/custom_components/myenergi/init.py", line 107, in _async_update_data await self.client.refresh()
The text was updated successfully, but these errors were encountered: