home-assistant / core

:house_with_garden: Open source home automation that puts local control and privacy first.
https://www.home-assistant.io
Apache License 2.0
74.07k stars 31.09k forks source link

Detected blocking call to import_module #131958

Open HeyITGuyFixIt opened 6 hours ago

HeyITGuyFixIt commented 6 hours ago

The problem

I'm getting an error in the logs that says to report it: "Detected blocking call to import_module with args ('homeassistant.components.dhcp',) in /usr/src/homeassistant/homeassistant/loader.py". Full log is below.

Not sure if this is related, could have a common cause, but I am also getting other errors and warnings after this one that the aiodns module wasn't found or couldn't load. My installation is largely broken due to that.

What version of Home Assistant Core has the issue?

core-2024.11.3

What was the last working version of Home Assistant Core?

core-2024.10.*

What type of installation are you running?

Home Assistant Container

Integration causing the issue

homeassistant.components.dhcp

Link to integration documentation on our website

https://www.home-assistant.io/integrations/dhcp/

Diagnostics information

No response

Example YAML snippet

No response

Anything in the logs that might be useful for us?

Logger: homeassistant.util.loop
Source: util/loop.py:77
First occurred: 9:36:25 AM (1 occurrences)
Last logged: 9:36:25 AM

Detected blocking call to import_module with args ('homeassistant.components.dhcp',) in /usr/src/homeassistant/homeassistant/loader.py, line 1071: ComponentProtocol, importlib.import_module(self.pkg_path) inside the event loop; This is causing stability issues. Please create a bug report at https://github.com/home-assistant/core/issues?q=is%3Aopen+is%3Aissue For developers, please see https://developers.home-assistant.io/docs/asyncio_blocking_operations/#import_module 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 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/setup.py", line 165, in async_setup_component result = await _async_setup_component(hass, domain, config) File "/usr/src/homeassistant/homeassistant/setup.py", line 334, in _async_setup_component component = await integration.async_get_component() File "/usr/src/homeassistant/homeassistant/loader.py", line 1023, in async_get_component comp = self._get_component() File "/usr/src/homeassistant/homeassistant/loader.py", line 1071, in _get_component ComponentProtocol, importlib.import_module(self.pkg_path)

Additional information

No response

home-assistant[bot] commented 6 hours ago

Hey there @bdraco, mind taking a look at this issue as it has been labeled with an integration (dhcp) you are listed as a code owner for? Thanks!

Code owner commands Code owners of `dhcp` can trigger bot actions by commenting: - `@home-assistant close` Closes the issue. - `@home-assistant rename Awesome new title` Renames the issue. - `@home-assistant reopen` Reopen the issue. - `@home-assistant unassign dhcp` Removes the current integration label and assignees on the issue, add the integration domain after the command. - `@home-assistant add-label needs-more-information` Add a label (needs-more-information, problem in dependency, problem in custom component) to the issue. - `@home-assistant remove-label needs-more-information` Remove a label (needs-more-information, problem in dependency, problem in custom component) on the issue.

(message by CodeOwnersMention)


dhcp documentation dhcp source (message by IssueLinks)

HeyITGuyFixIt commented 6 hours ago

This is running on a Raspberry Pi 4B in a Docker Container. I tried rebooting HA in safe made and it still gets this warning. And other components are still complaining about aiodns.

HeyITGuyFixIt commented 6 hours ago

Looks like I had previously modified the container command to also install GCC and G++, upgrade pip, and run pip install globally, and then call init. After commenting out that in my docker-compose.yaml, it started working without issue. Not sure why those commands caused issues, but it seems like that was the culprit.

HeyITGuyFixIt commented 5 hours ago

I spoke too soon. Looks like it didn't change anything. I may have looked at the system too soon after restarting it with docker compose up.

HeyITGuyFixIt commented 5 hours ago

Another issue mentioned running pip3 install --upgrade --force-reinstall for another package. So I tried that for aiodns and restarted HA. That fixed both this issue and the aiodns issue. Not sure what that means the issue was, but it seems to be working now.

I took a screenshot of the installation output. (Running from Termius on my phone) I didn't get a chance to copy the output.

Screenshot_20241130-103912

bdraco commented 4 hours ago

It looks like the blocking call was a result of missing required deps and the import was failing. Do you have any custom components installs that may have downgraded one of the required deps to a non-working version?