Skip to content
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 import_module with args ('homeassistant.components.nest',) in /usr/lib/python3.12/site-packages/homeassistant/loader.py, line 1050: ComponentProtocol, importlib.import_module(self.pkg_path) inside the event loop; #121521

Closed
brianjmurrell opened this issue Jul 8, 2024 · 8 comments

Comments

@brianjmurrell
Copy link

The problem

Got an error in my logs:

Logger: homeassistant.util.loop
Source: util/loop.py:77
First occurred: 6:34:13 AM (1 occurrences)
Last logged: 6:34:13 AM

Detected blocking call to import_module with args ('homeassistant.components.nest',) in /usr/lib/python3.12/site-packages/homeassistant/loader.py, line 1050: 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 "/usr/bin/hass", line 8, in <module> sys.exit(main()) File "/usr/lib/python3.12/site-packages/homeassistant/__main__.py", line 209, in main exit_code = runner.run(runtime_conf) File "/usr/lib/python3.12/site-packages/homeassistant/runner.py", line 190, in run return loop.run_until_complete(setup_and_run_hass(runtime_config)) File "/usr/lib64/python3.12/asyncio/base_events.py", line 674, in run_until_complete self.run_forever() File "/usr/lib64/python3.12/asyncio/base_events.py", line 641, in run_forever self._run_once() File "/usr/lib64/python3.12/asyncio/base_events.py", line 1987, in _run_once handle._run() File "/usr/lib64/python3.12/asyncio/events.py", line 88, in _run self._context.run(self._callback, *self._args) File "/usr/lib/python3.12/site-packages/homeassistant/setup.py", line 167, in async_setup_component result = await _async_setup_component(hass, domain, config) File "/usr/lib/python3.12/site-packages/homeassistant/setup.py", line 322, in _async_setup_component component = await integration.async_get_component() File "/usr/lib/python3.12/site-packages/homeassistant/loader.py", line 1002, in async_get_component comp = self._get_component() File "/usr/lib/python3.12/site-packages/homeassistant/loader.py", line 1050, in _get_component ComponentProtocol, importlib.import_module(self.pkg_path)

The above was followed by:

Logger: homeassistant.loader
Source: loader.py:1050
First occurred: 6:34:13 AM (2 occurrences)
Last logged: 6:34:13 AM

Unexpected exception importing component homeassistant.components.nest
Traceback (most recent call last):
  File "/usr/lib/python3.12/site-packages/homeassistant/loader.py", line 1050, in _get_component
    ComponentProtocol, importlib.import_module(self.pkg_path)
                       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.12/site-packages/homeassistant/util/loop.py", line 200, in protected_loop_func
    return func(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib64/python3.12/importlib/__init__.py", line 90, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "<frozen importlib._bootstrap>", line 1387, in _gcd_import
  File "<frozen importlib._bootstrap>", line 1360, in _find_and_load
  File "<frozen importlib._bootstrap>", line 1331, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 935, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 995, in exec_module
  File "<frozen importlib._bootstrap>", line 488, in _call_with_frames_removed
  File "/usr/lib/python3.12/site-packages/homeassistant/components/nest/__init__.py", line 12, in <module>
    from google_nest_sdm.camera_traits import CameraClipPreviewTrait
  File "/home/homeassistant/.homeassistant/deps/lib/python3.12/site-packages/google_nest_sdm/camera_traits.py", line 17, in <module>
    from .event import (
  File "/home/homeassistant/.homeassistant/deps/lib/python3.12/site-packages/google_nest_sdm/event.py", line 369, in <module>
    class EventMessage(DataClassDictMixin):
  File "/home/homeassistant/.homeassistant/deps/lib/python3.12/site-packages/mashumaro/mixins/dict.py", line 24, in __init_subclass__
    compile_mixin_unpacker(cls, **builder_params["unpacker"])
  File "/home/homeassistant/.homeassistant/deps/lib/python3.12/site-packages/mashumaro/core/meta/mixin.py", line 49, in compile_mixin_unpacker
    builder.add_unpack_method()
  File "/home/homeassistant/.homeassistant/deps/lib/python3.12/site-packages/mashumaro/core/meta/code/builder.py", line 557, in add_unpack_method
    self._add_unpack_method_lines(method_name)
  File "/home/homeassistant/.homeassistant/deps/lib/python3.12/site-packages/mashumaro/core/meta/code/builder.py", line 462, in _add_unpack_method_lines
    ).build(
      ^^^^^^
  File "/home/homeassistant/.homeassistant/deps/lib/python3.12/site-packages/mashumaro/core/meta/code/builder.py", line 1276, in build
    unpacked_value = UnpackerRegistry.get(
                     ^^^^^^^^^^^^^^^^^^^^^
  File "/home/homeassistant/.homeassistant/deps/lib/python3.12/site-packages/mashumaro/core/meta/types/common.py", line 238, in get
    expr = packer(spec)
           ^^^^^^^^^^^^
  File "/home/homeassistant/.homeassistant/deps/lib/python3.12/site-packages/mashumaro/core/meta/types/unpack.py", line 711, in unpack_special_typing_primitive
    uv = UnpackerRegistry.get(spec.copy(type=arg))
         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/homeassistant/.homeassistant/deps/lib/python3.12/site-packages/mashumaro/core/meta/types/common.py", line 238, in get
    expr = packer(spec)
           ^^^^^^^^^^^^
  File "/home/homeassistant/.homeassistant/deps/lib/python3.12/site-packages/mashumaro/core/meta/types/unpack.py", line 553, in unpack_type_with_overridden_deserialization
    deserialization_method = get_overridden_deserialization_method(spec)
                             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/homeassistant/.homeassistant/deps/lib/python3.12/site-packages/mashumaro/core/meta/types/unpack.py", line 539, in get_overridden_deserialization_method
    _unpack_with_annotated_serialization_strategy(
  File "/home/homeassistant/.homeassistant/deps/lib/python3.12/site-packages/mashumaro/core/meta/types/unpack.py", line 506, in _unpack_with_annotated_serialization_strategy
    value_type = spec.builder.evaluate_forward_ref(
                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/homeassistant/.homeassistant/deps/lib/python3.12/site-packages/mashumaro/core/meta/code/builder.py", line 339, in evaluate_forward_ref
    return evaluate_forward_ref(typ, globalns, self.__dict__)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/homeassistant/.homeassistant/deps/lib/python3.12/site-packages/mashumaro/core/meta/helpers.py", line 769, in evaluate_forward_ref
    return typ._evaluate(
           ^^^^^^^^^^^^^^
TypeError: ForwardRef._evaluate() missing 1 required keyword-only argument: 'recursive_guard'

And:

Logger: homeassistant.setup
Source: setup.py:322
First occurred: 6:34:13 AM (1 occurrences)
Last logged: 6:34:13 AM

Setup failed for 'nest': Unable to import component: Exception importing homeassistant.components.nest
Traceback (most recent call last):
  File "/usr/lib/python3.12/site-packages/homeassistant/loader.py", line 1050, in _get_component
    ComponentProtocol, importlib.import_module(self.pkg_path)
                       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.12/site-packages/homeassistant/util/loop.py", line 200, in protected_loop_func
    return func(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib64/python3.12/importlib/__init__.py", line 90, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "<frozen importlib._bootstrap>", line 1387, in _gcd_import
  File "<frozen importlib._bootstrap>", line 1360, in _find_and_load
  File "<frozen importlib._bootstrap>", line 1331, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 935, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 995, in exec_module
  File "<frozen importlib._bootstrap>", line 488, in _call_with_frames_removed
  File "/usr/lib/python3.12/site-packages/homeassistant/components/nest/__init__.py", line 12, in <module>
    from google_nest_sdm.camera_traits import CameraClipPreviewTrait
  File "/home/homeassistant/.homeassistant/deps/lib/python3.12/site-packages/google_nest_sdm/camera_traits.py", line 17, in <module>
    from .event import (
  File "/home/homeassistant/.homeassistant/deps/lib/python3.12/site-packages/google_nest_sdm/event.py", line 369, in <module>
    class EventMessage(DataClassDictMixin):
  File "/home/homeassistant/.homeassistant/deps/lib/python3.12/site-packages/mashumaro/mixins/dict.py", line 24, in __init_subclass__
    compile_mixin_unpacker(cls, **builder_params["unpacker"])
  File "/home/homeassistant/.homeassistant/deps/lib/python3.12/site-packages/mashumaro/core/meta/mixin.py", line 49, in compile_mixin_unpacker
    builder.add_unpack_method()
  File "/home/homeassistant/.homeassistant/deps/lib/python3.12/site-packages/mashumaro/core/meta/code/builder.py", line 557, in add_unpack_method
    self._add_unpack_method_lines(method_name)
  File "/home/homeassistant/.homeassistant/deps/lib/python3.12/site-packages/mashumaro/core/meta/code/builder.py", line 462, in _add_unpack_method_lines
    ).build(
      ^^^^^^
  File "/home/homeassistant/.homeassistant/deps/lib/python3.12/site-packages/mashumaro/core/meta/code/builder.py", line 1276, in build
    unpacked_value = UnpackerRegistry.get(
                     ^^^^^^^^^^^^^^^^^^^^^
  File "/home/homeassistant/.homeassistant/deps/lib/python3.12/site-packages/mashumaro/core/meta/types/common.py", line 238, in get
    expr = packer(spec)
           ^^^^^^^^^^^^
  File "/home/homeassistant/.homeassistant/deps/lib/python3.12/site-packages/mashumaro/core/meta/types/unpack.py", line 711, in unpack_special_typing_primitive
    uv = UnpackerRegistry.get(spec.copy(type=arg))
         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/homeassistant/.homeassistant/deps/lib/python3.12/site-packages/mashumaro/core/meta/types/common.py", line 238, in get
    expr = packer(spec)
           ^^^^^^^^^^^^
  File "/home/homeassistant/.homeassistant/deps/lib/python3.12/site-packages/mashumaro/core/meta/types/unpack.py", line 553, in unpack_type_with_overridden_deserialization
    deserialization_method = get_overridden_deserialization_method(spec)
                             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/homeassistant/.homeassistant/deps/lib/python3.12/site-packages/mashumaro/core/meta/types/unpack.py", line 539, in get_overridden_deserialization_method
    _unpack_with_annotated_serialization_strategy(
  File "/home/homeassistant/.homeassistant/deps/lib/python3.12/site-packages/mashumaro/core/meta/types/unpack.py", line 506, in _unpack_with_annotated_serialization_strategy
    value_type = spec.builder.evaluate_forward_ref(
                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/homeassistant/.homeassistant/deps/lib/python3.12/site-packages/mashumaro/core/meta/code/builder.py", line 339, in evaluate_forward_ref
    return evaluate_forward_ref(typ, globalns, self.__dict__)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/homeassistant/.homeassistant/deps/lib/python3.12/site-packages/mashumaro/core/meta/helpers.py", line 769, in evaluate_forward_ref
    return typ._evaluate(
           ^^^^^^^^^^^^^^
TypeError: ForwardRef._evaluate() missing 1 required keyword-only argument: 'recursive_guard'

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/usr/lib/python3.12/site-packages/homeassistant/loader.py", line 990, in async_get_component
    comp = await self.hass.async_add_import_executor_job(
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib64/python3.12/concurrent/futures/thread.py", line 58, in run
    result = self.fn(*self.args, **self.kwargs)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.12/site-packages/homeassistant/loader.py", line 1061, in _get_component
    raise ImportError(f"Exception importing {self.pkg_path}") from err
ImportError: Exception importing homeassistant.components.nest

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/lib/python3.12/site-packages/homeassistant/loader.py", line 1050, in _get_component
    ComponentProtocol, importlib.import_module(self.pkg_path)
                       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.12/site-packages/homeassistant/util/loop.py", line 200, in protected_loop_func
    return func(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib64/python3.12/importlib/__init__.py", line 90, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "<frozen importlib._bootstrap>", line 1387, in _gcd_import
  File "<frozen importlib._bootstrap>", line 1360, in _find_and_load
  File "<frozen importlib._bootstrap>", line 1331, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 935, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 995, in exec_module
  File "<frozen importlib._bootstrap>", line 488, in _call_with_frames_removed
  File "/usr/lib/python3.12/site-packages/homeassistant/components/nest/__init__.py", line 12, in <module>
    from google_nest_sdm.camera_traits import CameraClipPreviewTrait
  File "/home/homeassistant/.homeassistant/deps/lib/python3.12/site-packages/google_nest_sdm/camera_traits.py", line 17, in <module>
    from .event import (
  File "/home/homeassistant/.homeassistant/deps/lib/python3.12/site-packages/google_nest_sdm/event.py", line 369, in <module>
    class EventMessage(DataClassDictMixin):
  File "/home/homeassistant/.homeassistant/deps/lib/python3.12/site-packages/mashumaro/mixins/dict.py", line 24, in __init_subclass__
    compile_mixin_unpacker(cls, **builder_params["unpacker"])
  File "/home/homeassistant/.homeassistant/deps/lib/python3.12/site-packages/mashumaro/core/meta/mixin.py", line 49, in compile_mixin_unpacker
    builder.add_unpack_method()
  File "/home/homeassistant/.homeassistant/deps/lib/python3.12/site-packages/mashumaro/core/meta/code/builder.py", line 557, in add_unpack_method
    self._add_unpack_method_lines(method_name)
  File "/home/homeassistant/.homeassistant/deps/lib/python3.12/site-packages/mashumaro/core/meta/code/builder.py", line 462, in _add_unpack_method_lines
    ).build(
      ^^^^^^
  File "/home/homeassistant/.homeassistant/deps/lib/python3.12/site-packages/mashumaro/core/meta/code/builder.py", line 1276, in build
    unpacked_value = UnpackerRegistry.get(
                     ^^^^^^^^^^^^^^^^^^^^^
  File "/home/homeassistant/.homeassistant/deps/lib/python3.12/site-packages/mashumaro/core/meta/types/common.py", line 238, in get
    expr = packer(spec)
           ^^^^^^^^^^^^
  File "/home/homeassistant/.homeassistant/deps/lib/python3.12/site-packages/mashumaro/core/meta/types/unpack.py", line 711, in unpack_special_typing_primitive
    uv = UnpackerRegistry.get(spec.copy(type=arg))
         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/homeassistant/.homeassistant/deps/lib/python3.12/site-packages/mashumaro/core/meta/types/common.py", line 238, in get
    expr = packer(spec)
           ^^^^^^^^^^^^
  File "/home/homeassistant/.homeassistant/deps/lib/python3.12/site-packages/mashumaro/core/meta/types/unpack.py", line 553, in unpack_type_with_overridden_deserialization
    deserialization_method = get_overridden_deserialization_method(spec)
                             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/homeassistant/.homeassistant/deps/lib/python3.12/site-packages/mashumaro/core/meta/types/unpack.py", line 539, in get_overridden_deserialization_method
    _unpack_with_annotated_serialization_strategy(
  File "/home/homeassistant/.homeassistant/deps/lib/python3.12/site-packages/mashumaro/core/meta/types/unpack.py", line 506, in _unpack_with_annotated_serialization_strategy
    value_type = spec.builder.evaluate_forward_ref(
                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/homeassistant/.homeassistant/deps/lib/python3.12/site-packages/mashumaro/core/meta/code/builder.py", line 339, in evaluate_forward_ref
    return evaluate_forward_ref(typ, globalns, self.__dict__)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/homeassistant/.homeassistant/deps/lib/python3.12/site-packages/mashumaro/core/meta/helpers.py", line 769, in evaluate_forward_ref
    return typ._evaluate(
           ^^^^^^^^^^^^^^
TypeError: ForwardRef._evaluate() missing 1 required keyword-only argument: 'recursive_guard'

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/usr/lib/python3.12/site-packages/homeassistant/setup.py", line 322, in _async_setup_component
    component = await integration.async_get_component()
                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.12/site-packages/homeassistant/loader.py", line 1010, in async_get_component
    self._component_future.result()
  File "/usr/lib/python3.12/site-packages/homeassistant/loader.py", line 1002, in async_get_component
    comp = self._get_component()
           ^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.12/site-packages/homeassistant/loader.py", line 1061, in _get_component
    raise ImportError(f"Exception importing {self.pkg_path}") from err
ImportError: Exception importing homeassistant.components.nest

Apologies for the poor formatting but that is exactly how it appears in the log viewer. Maybe some formatting improvements can be made there.

What version of Home Assistant Core has the issue?

System Information version | core-2024.7.0 -- | -- installation_type | Unknown dev | false hassio | false docker | false user | homeassistant virtualenv | false python_version | 3.12.4 os_name | Linux os_version | 6.9.5-200.fc40.x86_64 arch | x86_64 timezone | [redacted] config_dir | /home/homeassistant/.homeassistant
Home Assistant Community Store GitHub API | ok -- | -- GitHub Content | ok GitHub Web | ok GitHub API Calls Remaining | 4935 Installed Version | 1.34.0 Stage | running Available Repositories | 1386 Downloaded Repositories | 5
Home Assistant Cloud logged_in | false -- | -- can_reach_cert_server | ok can_reach_cloud_auth | ok can_reach_cloud | ok
Dashboards dashboards | 7 -- | -- resources | 2 views | 9 mode | storage
Recorder oldest_recorder_run | June 23, 2024 at 12:47 PM -- | -- current_recorder_run | July 8, 2024 at 6:32 AM estimated_db_size | 93.71 MiB database_engine | sqlite database_version | 3.45.1

What was the last working version of Home Assistant Core?

No response

What type of installation are you running?

Home Assistant Core

Integration causing the issue

nest

Link to integration documentation on our website

No response

Diagnostics information

N/A for Nest:

image

Example YAML snippet

No response

Anything in the logs that might be useful for us?

See above.

Additional information

No response

@home-assistant
Copy link

home-assistant bot commented Jul 8, 2024

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

Code owner commands

Code owners of nest 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 nest 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)


nest documentation
nest source
(message by IssueLinks)

@allenporter
Copy link
Contributor

@bdraco the blocking call here appears to be in home assistant itself, right? Otherwise i believe this is a dupe of #119223

@elupus
Copy link
Contributor

elupus commented Jul 8, 2024

Ive seen similar too. I wonder if the issue is in mashumaro

@Floriszz
Copy link

Floriszz commented Jul 8, 2024

I have other integration suffer of the same issue. After restore to 2024.6.4 all worked right away again. This is not a solution but workaround for the time being.

@bdraco
Copy link
Member

bdraco commented Jul 8, 2024

I think this is the python 3.12.4 breaking change causing the problem Fatal1ty/mashumaro#226 Fatal1ty/mashumaro#231

TypeError: ForwardRef._evaluate() missing 1 required keyword-only argument: 'recursive_guard'

@bdraco
Copy link
Member

bdraco commented Jul 8, 2024

Maybe mashumaro needs a pin to a minimum version

@bdraco
Copy link
Member

bdraco commented Jul 8, 2024

@bdraco the blocking call here appears to be in home assistant itself, right? Otherwise i believe this is a dupe of #119223

Its a dupe of #119223

@allenporter
Copy link
Contributor

Marking duplicate of #119223

@github-actions github-actions bot locked and limited conversation to collaborators Aug 8, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

6 participants