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
69.72k stars 28.88k forks source link

qBittorrent integration won't load #120742

Closed sambarlick closed 1 day ago

sambarlick commented 5 days ago

The problem

Integration "won't load". I can't Reload the integration, remove or re-add the integration. I first noticed the issue on HA 2024.6.3 and I'm currently on 2024.7.0b3.

I have attached screenshots of the integration not being loaded and the error message I get when I try re-add.the integration.

I have copied the logs below and I don't have the option available to download the debug logs.

Screenshot_20240628-203704

Screenshot_20240628-203825

What version of Home Assistant Core has the issue?

2024.7.0b3

What was the last working version of Home Assistant Core?

2024.6.2

What type of installation are you running?

Home Assistant OS

Integration causing the issue

qBittorrent

Link to integration documentation on our website

https://rc.home-assistant.io/integrations/qbittorrent

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:51
First occurred: 20:33:30 (1 occurrences)
Last logged: 20:33:30

Detected blocking call to import_module with args ('homeassistant.components.qbittorrent',) in /usr/src/homeassistant/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 "<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/setup.py", line 167, in async_setup_component result = await _async_setup_component(hass, domain, config) File "/usr/src/homeassistant/homeassistant/setup.py", line 322, in _async_setup_component component = await integration.async_get_component() File "/usr/src/homeassistant/homeassistant/loader.py", line 1002, in async_get_component comp = self._get_component() File "/usr/src/homeassistant/homeassistant/loader.py", line 1050, in _get_component ComponentProtocol, importlib.import_module(self.pkg_path)

Logger: homeassistant.setup
Source: setup.py:322
First occurred: 20:33:30 (1 occurrences)
Last logged: 20:33:30

Setup failed for 'qbittorrent': Unable to import component: cannot import name 'TorrentStatusesT' from 'qbittorrentapi.torrents' (/usr/local/lib/python3.12/site-packages/qbittorrentapi/torrents.py)
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/loader.py", line 990, in async_get_component
    comp = await self.hass.async_add_import_executor_job(
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/concurrent/futures/thread.py", line 58, in run
    result = self.fn(*self.args, **self.kwargs)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/loader.py", line 1050, in _get_component
    ComponentProtocol, importlib.import_module(self.pkg_path)
                       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/util/loop.py", line 149, in protected_loop_func
    return func(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/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/src/homeassistant/homeassistant/components/qbittorrent/__init__.py", line 30, in <module>
    from .coordinator import QBittorrentDataCoordinator
  File "/usr/src/homeassistant/homeassistant/components/qbittorrent/coordinator.py", line 16, in <module>
    from qbittorrentapi.torrents import TorrentStatusesT
ImportError: cannot import name 'TorrentStatusesT' from 'qbittorrentapi.torrents' (/usr/local/lib/python3.12/site-packages/qbittorrentapi/torrents.py). Did you mean: 'TorrentStates'?

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/setup.py", line 322, in _async_setup_component
    component = await integration.async_get_component()
                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/loader.py", line 1010, in async_get_component
    self._component_future.result()
  File "/usr/src/homeassistant/homeassistant/loader.py", line 1002, in async_get_component
    comp = self._get_component()
           ^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/loader.py", line 1050, in _get_component
    ComponentProtocol, importlib.import_module(self.pkg_path)
                       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/util/loop.py", line 149, in protected_loop_func
    return func(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/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/src/homeassistant/homeassistant/components/qbittorrent/__init__.py", line 30, in <module>
    from .coordinator import QBittorrentDataCoordinator
  File "/usr/src/homeassistant/homeassistant/components/qbittorrent/coordinator.py", line 16, in <module>
    from qbittorrentapi.torrents import TorrentStatusesT
ImportError: cannot import name 'TorrentStatusesT' from 'qbittorrentapi.torrents' (/usr/local/lib/python3.12/site-packages/qbittorrentapi/torrents.py). Did you mean: 'TorrentStates'?

Additional information

I don't have the option to be able to download the debug logs. Is this due to the integration not being loaded?

home-assistant[bot] commented 5 days ago

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

Code owner commands Code owners of `qbittorrent` 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 qbittorrent` 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)


qbittorrent documentation qbittorrent source (message by IssueLinks)

finder39 commented 4 days ago

@sebclem I believe that 2024.7.0 would be the first time your changes in #107637 would be brought into the main branch for release. Can you take a look at this?

Sebclem commented 4 days ago

@sebclem I believe that 2024.7.0 would be the first time your changes in #107637 would be brought into the main branch for release. Can you take a look at this?

I'll take a look

Sebclem commented 4 days ago

@sambarlick Can you try upgrading to beta 4 ? I can't reproduce this with beta 4

Sebclem commented 4 days ago

@finder39 I don't think this is linked to the lib change, the issue seams to have already been present in 2024.6.3

I first noticed the issue on HA 2024.6.3 and I'm currently on 2024.7.0b3.

sambarlick commented 4 days ago

@sambarlick Can you try upgrading to beta 4 ? I can't reproduce this with beta 4

I just updated to beta 4 and it's fixed. I don't know if the issue is related to the recent changes made but I definitely had this issue prior to the 07 beta.

Thank you.

sambarlick commented 2 days ago

I have just updated to beta 6 and the issue has returned. Exactly the same as before.

Sebclem commented 2 days ago

I still can't reproduce this on beta 6, @finder39 did you manage to reproduce this ?

sambarlick commented 2 days ago

I don't know if there is anything in these logs that is useful. Also I don't know if it is helpful but the custom hacs integration "qBittorrent alternative speed switch for Home Assistant" still works for me.

Logger: homeassistant.util.loop Source: util/loop.py:51 First occurred: 07:58:09 (1 occurrences) Last logged: 07:58:09

Detected blocking call to import_module with args ('homeassistant.components.qbittorrent',) in /usr/src/homeassistant/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 "", 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 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/setup.py", line 167, in async_setup_component result = await _async_setup_component(hass, domain, config) File "/usr/src/homeassistant/homeassistant/setup.py", line 322, in _async_setup_component component = await integration.async_get_component() File "/usr/src/homeassistant/homeassistant/loader.py", line 1002, in async_get_component comp = self._get_component() File "/usr/src/homeassistant/homeassistant/loader.py", line 1050, in _get_component ComponentProtocol, importlib.import_module(self.pkg_path)

Logger: homeassistant.setup Source: setup.py:322 First occurred: 07:58:09 (1 occurrences) Last logged: 07:58:09

Setup failed for 'qbittorrent': Unable to import component: cannot import name 'TorrentStatusesT' from 'qbittorrentapi.torrents' (/usr/local/lib/python3.12/site-packages/qbittorrentapi/torrents.py) Traceback (most recent call last): File "/usr/src/homeassistant/homeassistant/loader.py", line 990, in async_get_component comp = await self.hass.async_add_import_executor_job( ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.12/concurrent/futures/thread.py", line 58, in run result = self.fn(*self.args, *self.kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/src/homeassistant/homeassistant/loader.py", line 1050, in _get_component ComponentProtocol, importlib.import_module(self.pkg_path) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/src/homeassistant/homeassistant/util/loop.py", line 149, in protected_loop_func return func(args, **kwargs) ^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.12/importlib/init.py", line 90, in import_module return _bootstrap._gcd_import(name[level:], package, level) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "", line 1387, in _gcd_import File "", line 1360, in _find_and_load File "", line 1331, in _find_and_load_unlocked File "", line 935, in _load_unlocked File "", line 995, in exec_module File "", line 488, in _call_with_frames_removed File "/usr/src/homeassistant/homeassistant/components/qbittorrent/init.py", line 30, in from .coordinator import QBittorrentDataCoordinator File "/usr/src/homeassistant/homeassistant/components/qbittorrent/coordinator.py", line 16, in from qbittorrentapi.torrents import TorrentStatusesT ImportError: cannot import name 'TorrentStatusesT' from 'qbittorrentapi.torrents' (/usr/local/lib/python3.12/site-packages/qbittorrentapi/torrents.py). Did you mean: 'TorrentStates'?

During handling of the above exception, another exception occurred:

Traceback (most recent call last): File "/usr/src/homeassistant/homeassistant/setup.py", line 322, in _async_setup_component component = await integration.async_get_component() ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/src/homeassistant/homeassistant/loader.py", line 1010, in async_get_component self._component_future.result() File "/usr/src/homeassistant/homeassistant/loader.py", line 1002, in async_get_component comp = self._get_component() ^^^^^^^^^^^^^^^^^^^^^ File "/usr/src/homeassistant/homeassistant/loader.py", line 1050, in _get_component ComponentProtocol, importlib.import_module(self.pkg_path) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/src/homeassistant/homeassistant/util/loop.py", line 149, in protected_loop_func return func(*args, **kwargs) ^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.12/importlib/init.py", line 90, in import_module return _bootstrap._gcd_import(name[level:], package, level) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "", line 1387, in _gcd_import File "", line 1360, in _find_and_load File "", line 1331, in _find_and_load_unlocked File "", line 935, in _load_unlocked File "", line 995, in exec_module File "", line 488, in _call_with_frames_removed File "/usr/src/homeassistant/homeassistant/components/qbittorrent/init.py", line 30, in from .coordinator import QBittorrentDataCoordinator File "/usr/src/homeassistant/homeassistant/components/qbittorrent/coordinator.py", line 16, in from qbittorrentapi.torrents import TorrentStatusesT ImportError: cannot import name 'TorrentStatusesT' from 'qbittorrentapi.torrents' (/usr/local/lib/python3.12/site-packages/qbittorrentapi/torrents.py). Did you mean: 'TorrentStates'?

frenck commented 1 day ago

I don't know if there is anything in these logs that is useful. Also I don't know if it is helpful but the custom hacs integration "qBittorrent alternative speed switch for Home Assistant" still works for me.

That one is actually the source of the problem, the custom integration override the library used.

The core integration uses:

qbittorrent-api==2024.2.59

See: https://github.com/home-assistant/core/blob/0ffebd4853c37cfca08f9d881b6c41cd76165273/homeassistant/components/qbittorrent/manifest.json#L10

The custom integration forces iy to:

qbittorrent-api==2022.5.32

See: https://github.com/JurajNyiri/HomeAssistant-qBitTorrentAlternativeSpeed/blob/d44e337fce96a66e54ba456715002ac4a4da4484/custom_components/qbittorrent_alternative_speed/manifest.json#L7

Which causes an incompatibility.

I'm going to close the issue on this end since the root cause is a custom integration, not Home Assistant itself. Please report this issue to the custom integration author.

../Frenck