Open Taraman17 opened 3 months ago
Looking into this, I treaced the blocking call down to yaml utils in homeassistant itself.
Issue created upstream: https://github.com/home-assistant/core/issues/119639
Nah. Issue is that you are calling load_yaml. You can't do that from event loop. Must be done in executor.
Hmm, I thought this could be a quick fix, but after doing
learned_dict = await self._hass.async_add_executor_job(load_yaml(self._config_dir + LEARNING_STORAGE_YAML))
I still get:
Detected blocking call to open inside the event loop by custom integration 'govee' at custom_components/govee/learning_storage.py, line 29:
learned_dict = await self._hass.async_add_executor_job(load_yaml(self._config_dir + LEARNING_STORAGE_YAML))
I'm confused...
edit: Nevermind - just saw, I have to pass arguments differently...
Hi,
I have encountered the same issue with the govee
custom integration on Home Assistant. Here are the details of my setup and the error logs:
2024-06-29 00:35:11.478 WARNING (MainThread) [homeassistant.util.loop] Detected blocking call to open inside the event loop by custom integration 'govee' at custom_components/govee/learning_storage.py, line 28: learned_dict = load_yaml(self._config_dir + LEARNING_STORAGE_YAML) (offender: /usr/src/homeassistant/homeassistant/util/yaml/loader.py, line 226: with open(fname, encoding="utf-8") as conf_file:), please create a bug report at https://github.com/LaggAt/hacs-govee/issues
Traceback (most recent call last):
File "<frozen runpy>", line 198, in _run_module_as_main
File "<frozen runpy>", line 88, in _run_code
File "/usr/src/homeassistant/homeassistant/__main__.py", line 223, in <module>
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 190, in run
return loop.run_until_complete(setup_and_run_hass(runtime_config))
File "/usr/local/lib/python3.12/asyncio/base_events.py", line 672, in run_until_complete
self.run_forever()
File "/usr/local/lib/python3.12/asyncio/base_events.py", line 639, in run_forever
self._run_once()
File "/usr/local/lib/python3.12/asyncio/base_events.py", line 1988, 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 742, in async_setup_locked
await self.async_setup(hass, integration=integration)
File "/usr/src/homeassistant/homeassistant/config_entries.py", line 594, in async_setup
result = await component.async_setup_entry(hass, self)
File "/config/custom_components/govee/__init__.py", line 64, in async_setup_entry
_, err = await hub.get_devices()
File "/usr/local/lib/python3.12/site-packages/govee_api_laggat/govee_api_laggat.py", line 312, in get_devices
_, err_api = await self._api.get_devices()
File "/usr/local/lib/python3.12/site-packages/govee_api_laggat/api.py", line 244, in get_devices
learning_infos = await self._govee._learning_storage._read_cached()
File "/usr/local/lib/python3.12/site-packages/govee_api_laggat/learning_storage.py", line 30, in _read_cached
self._learned_info = await self.read()
File "/config/custom_components/govee/learning_storage.py", line 28, in read
learned_dict = load_yaml(self._config_dir + LEARNING_STORAGE_YAML)
the same here:
Rejestrator: homeassistant.util.loop
Źródło: util/loop.py:136
Pierwsze zdarzenie: 13:01:19 (1 zdarzenia)
Ostatnio zalogowany: 13:01:19
Detected blocking call to open with args ('/config/govee_learning.yaml',) inside the event loop by custom integration 'govee' at custom_components/govee/learning_storage.py, line 28: learned_dict = load_yaml(self._config_dir + LEARNING_STORAGE_YAML) (offender: /usr/src/homeassistant/homeassistant/util/yaml/loader.py, line 226: with open(fname, encoding="utf-8") as conf_file:), please create a bug report at https://github.com/LaggAt/hacs-govee/issues For developers, please see https://developers.home-assistant.io/docs/asyncio_blocking_operations/#open Traceback (most recent call last): File "<frozen runpy>", line 198, in _run_module_as_main File "<frozen runpy>", line 88, in _run_code File "/usr/src/homeassistant/homeassistant/__main__.py", line 223, in <module> 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 190, 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 734, in async_setup_locked await self.async_setup(hass, integration=integration) File "/usr/src/homeassistant/homeassistant/config_entries.py", line 586, in async_setup result = await component.async_setup_entry(hass, self) File "/config/custom_components/govee/__init__.py", line 64, in async_setup_entry _, err = await hub.get_devices() File "/usr/local/lib/python3.12/site-packages/govee_api_laggat/govee_api_laggat.py", line 312, in get_devices _, err_api = await self._api.get_devices() File "/usr/local/lib/python3.12/site-packages/govee_api_laggat/api.py", line 244, in get_devices learning_infos = await self._govee._learning_storage._read_cached() File "/usr/local/lib/python3.12/site-packages/govee_api_laggat/learning_storage.py", line 30, in _read_cached self._learned_info = await self.read() File "/config/custom_components/govee/learning_storage.py", line 28, in read learned_dict = load_yaml(self._config_dir + LEARNING_STORAGE_YAML)
I'm also encountering this issue.
Core 2024.7.0 Supervisor 2024.06.2 Operating System 12.4 Frontend 20240703.0 HACS Govee integration 2023.11.1.
Logger: homeassistant.util.loop
Source: util/loop.py:136
Detected blocking call to open with args ('/config/govee_learning.yaml',) inside the event loop by custom integration 'govee' at custom_components/govee/learning_storage.py, line 28: learned_dict = load_yaml(self._config_dir + LEARNING_STORAGE_YAML) (offender: /usr/src/homeassistant/homeassistant/util/yaml/loader.py, line 226: with open(fname, encoding="utf-8") as conf_file:), please create a bug report at https://github.com/LaggAt/hacs-govee/issues For developers, please see https://developers.home-assistant.io/docs/asyncio_blocking_operations/#open Traceback (most recent call last): File "<frozen runpy>", line 198, in _run_module_as_main File "<frozen runpy>", line 88, in _run_code File "/usr/src/homeassistant/homeassistant/__main__.py", line 223, in <module> 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 190, 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 734, in async_setup_locked await self.async_setup(hass, integration=integration) File "/usr/src/homeassistant/homeassistant/config_entries.py", line 586, in async_setup result = await component.async_setup_entry(hass, self) File "/config/custom_components/govee/__init__.py", line 64, in async_setup_entry _, err = await hub.get_devices() File "/usr/local/lib/python3.12/site-packages/govee_api_laggat/govee_api_laggat.py", line 312, in get_devices _, err_api = await self._api.get_devices() File "/usr/local/lib/python3.12/site-packages/govee_api_laggat/api.py", line 244, in get_devices learning_infos = await self._govee._learning_storage._read_cached() File "/usr/local/lib/python3.12/site-packages/govee_api_laggat/learning_storage.py", line 30, in _read_cached self._learned_info = await self.read() File "/config/custom_components/govee/learning_storage.py", line 28, in read learned_dict = load_yaml(self._config_dir + LEARNING_STORAGE_YAML)
Detected blocking call to open with args ('/config/.matrix.conf',) inside the event loop by integration 'matrix' at homeassistant/components/matrix/__init__.py, line 345: return load_json_object(self._session_filepath) (offender: /usr/src/homeassistant/homeassistant/util/json.py, line 78: with open(filename, mode="rb") as fdesc:), please create a bug report at https://github.com/home-assistant/core/issues?q=is%3Aopen+is%3Aissue+label%3A%22integration%3A+matrix%22 For developers, please see https://developers.home-assistant.io/docs/asyncio_blocking_operations/#open Traceback (most recent call last): File "<frozen runpy>", line 198, in _run_module_as_main File "<frozen runpy>", line 88, in _run_code File "/usr/src/homeassistant/homeassistant/__main__.py", line 223, in <module> 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 190, 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/runner.py", line 166, in setup_and_run_hass return await hass.async_run() File "/usr/src/homeassistant/homeassistant/core.py", line 523, in async_run await self.async_start() File "/usr/src/homeassistant/homeassistant/core.py", line 542, in async_start self.bus.async_fire_internal(EVENT_HOMEASSISTANT_START) File "/usr/src/homeassistant/homeassistant/core.py", line 1559, in async_fire_internal self._hass.async_run_hass_job(job, event) File "/usr/src/homeassistant/homeassistant/core.py", line 938, in async_run_hass_job hassjob.target(*args) File "/usr/src/homeassistant/homeassistant/core.py", line 1420, in __call__ self.hass.async_run_hass_job(self.listener_job, event) File "/usr/src/homeassistant/homeassistant/core.py", line 941, in async_run_hass_job return self._async_add_hass_job(hassjob, *args, background=background) File "/usr/src/homeassistant/homeassistant/core.py", line 756, in _async_add_hass_job task = create_eager_task( File "/usr/src/homeassistant/homeassistant/util/async_.py", line 37, in create_eager_task return Task(coro, loop=loop, name=name, eager_start=True) File "/usr/src/homeassistant/homeassistant/components/matrix/__init__.py", line 207, in handle_startup self._access_tokens = await self._get_auth_tokens() File "/usr/src/homeassistant/homeassistant/components/matrix/__init__.py", line 345, in _get_auth_tokens return load_json_object(self._session_filepath)
Version of the custom_component
2023.11.1
Configuration
Standard configuration via UI
Describe the bug
HA Logs show the above warning. This is issued since 2024.6.0 and will most likely lead to an error in the future.
Full log entry below.
Error (Warning) log