KoljaWindeler / ytube_music_player

YouTube music player for homeassistant
338 stars 53 forks source link

HA 2024.8.2 - Detected code that calls async_forward_entry_setup for integration ytube_music_player with title #357

Open StefanoGiu opened 2 months ago

StefanoGiu commented 2 months ago

2024-08-21 13:39:53.227 WARNING (MainThread) [homeassistant.helpers.frame] Detected code that calls async_forward_entry_setup for integration ytube_music_player with title: yTubeMusic and entry_id: XXXX, during setup without awaiting async_forward_entry_setup, which can cause the setup lock to be released before the setup is done. This will stop working in Home Assistant 2025.1. Please report this issue. Stack (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/config_entries.py", line 2161, in async_forward_entry_setup _report_non_awaited_platform_forwards(entry, "async_forward_entry_setup") File "/usr/src/homeassistant/homeassistant/config_entries.py", line 1201, in _report_non_awaited_platform_forwards report( File "/usr/src/homeassistant/homeassistant/helpers/frame.py", line 151, in report _LOGGER.warning(msg, stack_info=True)

StefanoGiu commented 2 months ago

I fixed it in this way in init.py

async def async_setup_entry(hass, config_entry):
.....
    # for platform in PLATFORMS:
        # hass.async_create_task(
            # hass.config_entries.async_forward_entry_setup(config_entry, platform)
        # )
    await hass.config_entries.async_forward_entry_setups(config_entry, PLATFORMS)

async def async_update_options(hass, config_entry):
    _LOGGER.debug("Config updated,reload the entities.")
    for platform in PLATFORMS:
        await hass.config_entries.async_forward_entry_unload(config_entry, platform)
        # hass.async_create_task(hass.config_entries.async_forward_entry_setup(config_entry, platform))
    await hass.config_entries.async_forward_entry_setups(config_entry, PLATFORMS)