hacs / integration

HACS gives you a powerful UI to handle downloads of all your custom needs.
https://hacs.xyz
MIT License
5.18k stars 1.25k forks source link

Detected blocking call inside the event loop #3889

Closed Cougar closed 1 month ago

Cougar commented 1 month ago

System Health details

System Information

version core-2024.7.2
installation_type Home Assistant OS
dev false
hassio true
docker true
user root
virtualenv false
python_version 3.12.4
os_name Linux
os_version 6.6.33-haos
arch x86_64
timezone Europe/Tallinn
config_dir /config
Home Assistant Community Store GitHub API | ok -- | -- GitHub Content | ok GitHub Web | ok GitHub API Calls Remaining | 4965 Installed Version | 1.34.0 Stage | running Available Repositories | 1390 Downloaded Repositories | 40
Home Assistant Cloud logged_in | false -- | -- can_reach_cert_server | ok can_reach_cloud_auth | ok can_reach_cloud | ok
Home Assistant Supervisor host_os | Home Assistant OS 12.4 -- | -- update_channel | stable supervisor_version | supervisor-2024.06.2 agent_version | 1.6.0 docker_version | 26.1.4 disk_total | 58.0 GB disk_used | 40.4 GB healthy | true supported | true host_connectivity | true supervisor_connectivity | true ntp_synchronized | true virtualization | board | generic-x86-64 supervisor_api | ok version_api | ok installed_addons | MariaDB (2.7.1), Mosquitto broker (6.4.1), ZeroTier One (0.18.0), TasmoAdmin (0.30.3), Node-RED (18.0.4), Studio Code Server (5.15.0), phpMyAdmin (0.9.1), Advanced SSH & Web Terminal (18.0.0), Log Viewer (0.17.0), NGINX Home Assistant SSL proxy (3.9.0), Syncthing (1.19.0), Docker Container Stats (1.5.0), SNMP Sensor Server (1.3.4), Tailscale (0.20.0), Prometheus Node Exporter (1.0.0), cAdvisor (0.0.8), Promtail (2.2.0), ZigStar TI CC2652P/P7 FW Flasher (0.4.0), Frigate (0.13.2), SkyConnect CP2102N Programmer (1.0.1), WireGuard (0.10.2), AdGuard Home (5.1.1), ESPHome (2024.6.6), Matter Server (6.2.1), Music Assistant (2.0.7)
Dashboards dashboards | 8 -- | -- resources | 23 views | 35 mode | storage
Recorder oldest_recorder_run | July 2, 2024 at 22:05 -- | -- current_recorder_run | July 11, 2024 at 17:33 estimated_db_size | 10148.19 MiB database_engine | mysql database_version | 10.11.6

Checklist

Describe the issue

This happened only once when I upgraded integration from HACS. I don't know how to reproduce it without waiting for the next upgrade and I'm not sure it will block long enough every time.

It could be related with multiple upgrades. I had two integration available for upgrade and applied it for both without waiting one to finish. In this case it should be detected and avoided earlier and not hit the HA loop.

This was first time I saw it but hopefully it gives some clue what was going on and helps devs.

2024-07-14 12:11:00.325 WARNING (MainThread) [homeassistant.util.loop] Detected blocking call to open with args ('/config/custom_components/powercalc/services.yaml', 'wb') inside the event loop by custom integration 'hacs' at custom_components/hacs/repositories/base.py, line 600: zip_file.extractall(self.content.path.local) (offender: /usr/local/lib/python3.12/zipfile/__init__.py, line 1801: open(targetpath, "wb") as target:), please create a bug report at https://github.com/hacs/integration/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/components/websocket_api/decorators.py", line 28, in _handle_async_response
    await func(hass, connection, msg)
  File "/config/custom_components/hacs/websocket/repository.py", line 234, in hacs_repository_download
    await repository.async_install()
  File "/config/custom_components/hacs/repositories/base.py", line 893, in async_install
    await self.async_install_repository(version=version)
  File "/config/custom_components/hacs/repositories/base.py", line 975, in async_install_repository
    await self.download_zip_files(self.validate)
  File "/config/custom_components/hacs/repositories/base.py", line 566, in download_zip_files
    await self.async_download_zip_file(
  File "/config/custom_components/hacs/repositories/base.py", line 600, in async_download_zip_file
    zip_file.extractall(self.content.path.local)

Reproduction steps

  1. Upgrade integration via HACS
  2. blocking call detected (not always)

Debug logs

No debug logs. Would enable it when I see it more often. This was one time error only.

Diagnostics dump

No response

hacs-bot[bot] commented 1 month ago

Make sure you have read the issue guidelines and that you filled out the entire template.

If you have an issue identical to this, do not add comments like "same here", "i have this too", instead add a :+1: reaction to the issue description. Thanks! :+1: