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 inside the event loop by custom integration 'zha_toolkit' #233

Closed
zalewskigrzegorz opened this issue Jun 17, 2024 · 2 comments

Comments

@zalewskigrzegorz
Copy link

Core
2024.6.3
Supervisor
2024.06.0
Operating System
12.3
UI
20240610.1

Full log:

2024-06-17 03:00:00.399 WARNING (MainThread) [homeassistant.util.loop] Detected blocking call to import_module inside the event loop by custom integration 'zha_toolkit' at custom_components/zha_toolkit/default.py, line 33: m = importlib.import_module(f".{module_name}", package=package_name) (offender: /config/custom_components/zha_toolkit/default.py, line 33: m = importlib.import_module(f".{module_name}", package=package_name)), please create a bug report at https://github.com/mdeweerd/zha-toolkit/issues
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 672, in run_until_complete
    self.run_forever()
  File "/usr/local/lib/python3.12/asyncio/base_events.py", line 639, in run_forever
    self._run_once()
  File "/usr/local/lib/python3.12/asyncio/base_events.py", line 1988, 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/helpers/event.py", line 1468, in __call__
    self.hass.async_run_hass_job(self.job, self.utc_point_in_time)
  File "/usr/src/homeassistant/homeassistant/core.py", line 936, in async_run_hass_job
    hassjob.target(*args)
  File "/usr/src/homeassistant/homeassistant/helpers/event.py", line 1781, in _pattern_time_change_listener
    hass.async_run_hass_job(self.job, localized_now, background=True)
  File "/usr/src/homeassistant/homeassistant/core.py", line 936, in async_run_hass_job
    hassjob.target(*args)
  File "/usr/src/homeassistant/homeassistant/components/homeassistant/triggers/time.py", line 68, in time_automation_listener
    hass.async_run_hass_job(
  File "/usr/src/homeassistant/homeassistant/core.py", line 939, in async_run_hass_job
    return self._async_add_hass_job(hassjob, *args, background=background)
  File "/usr/src/homeassistant/homeassistant/core.py", line 748, in _async_add_hass_job
    task = create_eager_task(
  File "/usr/src/homeassistant/homeassistant/util/async_.py", line 37, in create_eager_task
    return Task(coro, loop=loop, name=name, eager_start=True)
  File "/usr/src/homeassistant/homeassistant/components/automation/__init__.py", line 826, in _async_trigger_if_enabled
    return await self.async_trigger(run_variables, context, skip_condition)
  File "/usr/src/homeassistant/homeassistant/components/automation/__init__.py", line 723, in async_trigger
    return await self.action_script.async_run(
  File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 1769, in async_run
    return await asyncio.shield(create_eager_task(run.async_run()))
  File "/usr/src/homeassistant/homeassistant/util/async_.py", line 37, in create_eager_task
    return Task(coro, loop=loop, name=name, eager_start=True)
  File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 464, in async_run
    await self._async_step(log_exceptions=False)
  File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 526, in _async_step
    await getattr(self, handler)()
  File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 764, in _async_call_service_step
    self._hass.async_create_task_internal(
  File "/usr/src/homeassistant/homeassistant/core.py", line 828, in async_create_task_internal
    task = create_eager_task(target, name=name, loop=self.loop)
  File "/usr/src/homeassistant/homeassistant/util/async_.py", line 37, in create_eager_task
    return Task(coro, loop=loop, name=name, eager_start=True)
  File "/usr/src/homeassistant/homeassistant/core.py", line 2741, in async_call
    response_data = await coro
  File "/usr/src/homeassistant/homeassistant/core.py", line 2784, in _execute_service
    return await target(service_call)
  File "/config/custom_components/zha_toolkit/__init__.py", line 781, in toolkit_service
    handler_result = await handler(
  File "/config/custom_components/zha_toolkit/__init__.py", line 891, in command_handler_default
    return await default.default(
  File "/config/custom_components/zha_toolkit/default.py", line 33, in default
    m = importlib.import_module(f".{module_name}", package=package_name)

2024-06-17 03:00:00.400 ERROR (MainThread) [custom_components.zha_toolkit] Exception 'znp_backup is only for ZNP' for service call with data '{'zha_toolkit_version': 'v1.1.10', 'zigpy_version': '0.64.1', 'zigpy_rf_version': '0.39.1', 'ieee_org': None, 'ieee': 'None', 'command': 'znp_backup', 'command_data': '_17', 'start_time': '2024-06-17T01:00:00.380549+00:00', 'errors': ["ValueError('znp_backup is only for ZNP')"], 'params': {'dir': 0, 'tries': 1, 'expect_reply': True, 'args': [], 'event_success': 'znp_backup_success', 'event_fail': 'znp_backup_failed', 'event_done': 'znp_backup_done', 'read_before_write': True, 'read_after_write': True}, 'success': False}'
2024-06-17 03:00:00.401 ERROR (MainThread) [homeassistant.components.automation.daily_znp_backup_monthly_rotation] Daily ZNP Backup - Monthly rotation: Error executing script. Unexpected error for call_service at pos 1: znp_backup is only for ZNP
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 526, in _async_step
    await getattr(self, handler)()
  File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 763, in _async_call_service_step
    response_data = await self._async_run_long_action(
                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 726, in _async_run_long_action
    return await long_task
           ^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/core.py", line 2741, in async_call
    response_data = await coro
                    ^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/core.py", line 2784, in _execute_service
    return await target(service_call)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/config/custom_components/zha_toolkit/__init__.py", line 825, in toolkit_service
    raise handler_exception
  File "/config/custom_components/zha_toolkit/__init__.py", line 781, in toolkit_service
    handler_result = await handler(
                     ^^^^^^^^^^^^^^
  File "/config/custom_components/zha_toolkit/__init__.py", line 891, in command_handler_default
    return await default.default(
           ^^^^^^^^^^^^^^^^^^^^^^
  File "/config/custom_components/zha_toolkit/default.py", line 40, in default
    await handler(app, listener, ieee, cmd, data, service, params, event_data)
  File "/config/custom_components/zha_toolkit/znp.py", line 23, in znp_backup
    raise ValueError(msg)
ValueError: znp_backup is only for ZNP
2024-06-17 03:00:00.402 ERROR (MainThread) [homeassistant.components.automation.daily_znp_backup_monthly_rotation] While executing automation automation.daily_znp_backup_monthly_rotation
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/components/automation/__init__.py", line 723, in async_trigger
    return await self.action_script.async_run(
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 1769, in async_run
    return await asyncio.shield(create_eager_task(run.async_run()))
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 464, in async_run
    await self._async_step(log_exceptions=False)
  File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 528, in _async_step
    self._handle_exception(
  File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 558, in _handle_exception
    raise exception
  File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 526, in _async_step
    await getattr(self, handler)()
  File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 763, in _async_call_service_step
    response_data = await self._async_run_long_action(
                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 726, in _async_run_long_action
    return await long_task
           ^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/core.py", line 2741, in async_call
    response_data = await coro
                    ^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/core.py", line 2784, in _execute_service
    return await target(service_call)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/config/custom_components/zha_toolkit/__init__.py", line 825, in toolkit_service
    raise handler_exception
  File "/config/custom_components/zha_toolkit/__init__.py", line 781, in toolkit_service
    handler_result = await handler(
                     ^^^^^^^^^^^^^^
  File "/config/custom_components/zha_toolkit/__init__.py", line 891, in command_handler_default
    return await default.default(
           ^^^^^^^^^^^^^^^^^^^^^^
  File "/config/custom_components/zha_toolkit/default.py", line 40, in default
    await handler(app, listener, ieee, cmd, data, service, params, event_data)
  File "/config/custom_components/zha_toolkit/znp.py", line 23, in znp_backup
    raise ValueError(msg)
ValueError: znp_backup is only for ZNP
@CordoWEB
Copy link

Workaround available here #224

@mdeweerd
Copy link
Owner

#224 Has been integrated in the release and this should be fixed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants