dummylabs / thewatchman

Home Assistant custom integration to keep track of missing entities and actions in your config files
MIT License
475 stars 20 forks source link

blocking call to iglob #139

Closed wiedwo closed 4 months ago

wiedwo commented 4 months ago

2024-07-07 15:32:46.842 WARNING (MainThread) [homeassistant.util.loop] Detected blocking call to iglob with args ('/config/*/.yaml',) inside the event loop by custom integration 'watchman' at custom_components/watchman/utils.py, line 160: for filename in glob.iglob(folder, recursive=True): (offender: /config/custom_components/watchman/utils.py, line 160: for filename in glob.iglob(folder, recursive=True):), please create a bug report at https://github.com/dummylabs/thewatchman/issues

dummylabs commented 4 months ago

It seems your version of Watchman is not recent, please update to 0.6.3.

chemelli74 commented 4 months ago

I'm on 0.6.3 but I still have the same report:

2024-07-08 10:57:15.878 WARNING (MainThread) [homeassistant.util.loop] Detected blocking call to scandir with args ('/config/',) inside the event loop by custom integration 'watchman' at custom_components/watchman/utils.py, line 160: for filename in glob.iglob(folder, recursive=True): (offender: /usr/local/lib/python3.12/glob.py, line 160: with os.scandir(arg) as it:), please create a bug report at https://github.com/andreasbrett/thewatchman/issues
For developers, please see https://developers.home-assistant.io/docs/asyncio_blocking_operations/#scandir
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/runner.py", line 166, in setup_and_run_hass
    return await hass.async_run()
  File "/usr/src/homeassistant/homeassistant/core.py", line 523, in async_run
    await self.async_start()
  File "/usr/src/homeassistant/homeassistant/core.py", line 576, in async_start
    self.bus.async_fire_internal(EVENT_HOMEASSISTANT_STARTED)
  File "/usr/src/homeassistant/homeassistant/core.py", line 1559, in async_fire_internal
    self._hass.async_run_hass_job(job, event)
  File "/usr/src/homeassistant/homeassistant/core.py", line 938, in async_run_hass_job
    hassjob.target(*args)
  File "/usr/src/homeassistant/homeassistant/core.py", line 1420, in __call__
    self.hass.async_run_hass_job(self.listener_job, event)
  File "/usr/src/homeassistant/homeassistant/core.py", line 941, in async_run_hass_job
    return self._async_add_hass_job(hassjob, *args, background=background)
  File "/usr/src/homeassistant/homeassistant/core.py", line 756, 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 "/config/custom_components/watchman/__init__.py", line 273, in async_on_home_assistant_started
    await parse_config(hass, reason="HA restart")
  File "/config/custom_components/watchman/__init__.py", line 350, in parse_config
    entity_list, service_list, files_parsed, files_ignored = await parse(
  File "/config/custom_components/watchman/utils.py", line 252, in parse
    for yaml_file, ignored in get_next_file(folders, ignored_files):
  File "/config/custom_components/watchman/utils.py", line 160, in get_next_file
    for filename in glob.iglob(folder, recursive=True):
dummylabs commented 4 months ago

I'd like you to check the actual version, displayed by integration. it is shown in Settings->Devices and services->Watchman (under the shield logo). If it's 0.6.3 then it may be that component was not properly updated. In version 0.6.3 anyio.Path.glob should be used instead of iglob (line 164): https://github.com/dummylabs/thewatchman/blob/v0.6.3/custom_components/watchman/utils.py#L164

You also may check /config/custom_components/watchman/utils.py for actual source files used by your instance of integration. If re-download doesn't help, I'd recommend to uninstall Watchman via HACS, remove /config/custom_components/watchman folder and install it again.