heyajohnny / afvalinfo

Provides Home Assistant sensors for multiple Dutch waste collectors. The idea is to add more cities and features in the future.
GNU General Public License v3.0
98 stars 22 forks source link

HASS Core version after 2024.06 reports blocking calls to format_date() function #449

Closed altserg closed 19 hours ago

altserg commented 1 month ago

It's probably already known, but I'm logging this issue to keep track of resolution:

2024-07-31 03:34:39.243 WARNING (MainThread) [homeassistant.util.loop] Detected blocking call to open with args ('/usr/local/hass/instance-1/lib/python3.12/site-packages/babel/global.dat', 'rb') inside the event loop by custom integration 'afvalinfo' at custom_components/afvalinfo/sensor.py, line 369: locale_date = format_date( (offender: /usr/local/hass/instance-1/lib/python3.12/site-packages/babel/core.py, line 75: with open(filename, 'rb') as fileobj:), please create a bug report at https://github.com/heyajohnny/afvalinfo/issues File "/home/hass/.homeassistant/custom_components/afvalinfo/sensor.py", line 369, in async_update 2024-07-31 03:34:39.283 WARNING (MainThread) [homeassistant.util.loop] Detected blocking call to open with args ('/usr/local/hass/instance-1/lib/python3.12/site-packages/babel/locale-data/root.dat', 'rb') inside the event loop by custom integration 'afvalinfo' at custom_components/afvalinfo/sensor.py, line 369: locale_date = format_date( (offender: /usr/local/hass/instance-1/lib/python3.12/site-packages/babel/localedata.py, line 123: with open(filename, 'rb') as fileobj:), please create a bug report at https://github.com/heyajohnny/afvalinfo/issues File "/home/hass/.homeassistant/custom_components/afvalinfo/sensor.py", line 369, in async_update

PuckStar commented 1 week ago

I have the same issue (version 2.3.1)

2024-09-08 17:21:13.261 WARNING (MainThread) [homeassistant.util.loop] Detected blocking call to open with args ('/usr/local/lib/python3.12/site-packages/babel/global.dat', 'rb') inside the event loop by custom integration 'afvalinfo' at custom_components/afvalinfo/sensor.py, line 369: locale_date = format_date( (offender: /usr/local/lib/python3.12/site-packages/babel/core.py, line 75: with open(filename, 'rb') as fileobj:), please create a bug report at https://github.com/heyajohnny/afvalinfo/issues
For developers, please see https://developers.home-assistant.io/docs/asyncio_blocking_operations/#open
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/helpers/entity_platform.py", line 678, in _async_handle_interval_callback
    self.config_entry.async_create_background_task(
  File "/usr/src/homeassistant/homeassistant/config_entries.py", line 1182, in async_create_background_task
    task = hass.async_create_background_task(target, name, eager_start)
  File "/usr/src/homeassistant/homeassistant/core.py", line 862, in async_create_background_task
    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/helpers/entity_platform.py", line 1052, in _async_update_entity_states
    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/helpers/entity.py", line 942, in async_update_ha_state
    await self.async_device_update()
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 1300, in async_device_update
    await self.async_update()
  File "/config/custom_components/afvalinfo/sensor.py", line 369, in async_update
    locale_date = format_date(

2024-09-08 17:21:13.292 WARNING (MainThread) [homeassistant.util.loop] Detected blocking call to open with args ('/usr/local/lib/python3.12/site-packages/babel/locale-data/root.dat', 'rb') inside the event loop by custom integration 'afvalinfo' at custom_components/afvalinfo/sensor.py, line 369: locale_date = format_date( (offender: /usr/local/lib/python3.12/site-packages/babel/localedata.py, line 123: with open(filename, 'rb') as fileobj:), please create a bug report at https://github.com/heyajohnny/afvalinfo/issues
For developers, please see https://developers.home-assistant.io/docs/asyncio_blocking_operations/#open
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/helpers/entity_platform.py", line 678, in _async_handle_interval_callback
    self.config_entry.async_create_background_task(
  File "/usr/src/homeassistant/homeassistant/config_entries.py", line 1182, in async_create_background_task
    task = hass.async_create_background_task(target, name, eager_start)
  File "/usr/src/homeassistant/homeassistant/core.py", line 862, in async_create_background_task
    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/helpers/entity_platform.py", line 1052, in _async_update_entity_states
    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/helpers/entity.py", line 942, in async_update_ha_state
    await self.async_device_update()
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 1300, in async_device_update
    await self.async_update()
  File "/config/custom_components/afvalinfo/sensor.py", line 369, in async_update
    locale_date = format_date(
heyajohnny commented 5 days ago

@PuckStar Does this also happen after a reboot? This should not happen if you've got the latest version of afvalinfo

altserg commented 4 days ago

I confirm the issue is present after update to HASS Core 2024.9.1 and restart.

heyajohnny commented 4 days ago

I'll keep the issue open, but it's not reproducable by me image It looks like something is being cached on your side that keeps some of the old code for afvalinfo

altserg commented 4 days ago

I have deleted all, .pyc files for the integration, re-downloaded version 2.3.1, rebooted the system and HASS Core. However, the issue is still there, see the log below. I do use non-default date format, and 2 instances of afvalinfo in one HASS installation for 2 different addresses. See my setting below. What other cache do I need to empty ?

image


2024-09-11 16:08:22.975 WARNING (MainThread) [homeassistant.util.loop] Detected blocking call to open with args ('/usr/local/hass/instance-2/lib/python3.12/site-packages/babel/global.dat', 'rb') inside the event loop by custom integration 'afvalinfo' at custom_components/afvalinfo/sensor.py, line 369: locale_date = format_date( (offender: /usr/local/hass/instance-2/lib/python3.12/site-packages/babel/core.py, line 75: with open(filename, 'rb') as fileobj:), please create a bug report at https://github.com/heyajohnny/afvalinfo/issues
For developers, please see https://developers.home-assistant.io/docs/asyncio_blocking_operations/#open
Traceback (most recent call last):
  File "/usr/local/hass/instance-2/bin/hass", line 8, in <module>
    sys.exit(main())
  File "/usr/local/hass/instance-2/lib/python3.12/site-packages/homeassistant/__main__.py", line 209, in main
    exit_code = runner.run(runtime_conf)
  File "/usr/local/hass/instance-2/lib/python3.12/site-packages/homeassistant/runner.py", line 189, in run
    return loop.run_until_complete(setup_and_run_hass(runtime_config))
  File "/usr/lib/python3.12/asyncio/base_events.py", line 672, in run_until_complete
    self.run_forever()
  File "/usr/lib/python3.12/asyncio/base_events.py", line 639, in run_forever
    self._run_once()
  File "/usr/lib/python3.12/asyncio/base_events.py", line 1985, in _run_once
    handle._run()
  File "/usr/lib/python3.12/asyncio/events.py", line 88, in _run
    self._context.run(self._callback, *self._args)
  File "/usr/local/hass/instance-2/lib/python3.12/site-packages/homeassistant/helpers/entity_platform.py", line 675, in _async_handle_interval_callback
    self.config_entry.async_create_background_task(
  File "/usr/local/hass/instance-2/lib/python3.12/site-packages/homeassistant/config_entries.py", line 1182, in async_create_background_task
    task = hass.async_create_background_task(target, name, eager_start)
  File "/usr/local/hass/instance-2/lib/python3.12/site-packages/homeassistant/core.py", line 861, in async_create_background_task
    task = create_eager_task(target, name=name, loop=self.loop)
  File "/usr/local/hass/instance-2/lib/python3.12/site-packages/homeassistant/util/async_.py", line 45, in create_eager_task
    return Task(coro, loop=loop, name=name, eager_start=True)
  File "/usr/local/hass/instance-2/lib/python3.12/site-packages/homeassistant/helpers/entity_platform.py", line 1041, in _async_update_entity_states
    create_eager_task(
  File "/usr/local/hass/instance-2/lib/python3.12/site-packages/homeassistant/util/async_.py", line 45, in create_eager_task
    return Task(coro, loop=loop, name=name, eager_start=True)
  File "/usr/local/hass/instance-2/lib/python3.12/site-packages/homeassistant/helpers/entity.py", line 942, in async_update_ha_state
    await self.async_device_update()
  File "/usr/local/hass/instance-2/lib/python3.12/site-packages/homeassistant/helpers/entity.py", line 1300, in async_device_update
    await self.async_update()
  File "/home/hass/.homeassistant/custom_components/afvalinfo/sensor.py", line 369, in async_update
    locale_date = format_date(

2024-09-11 16:08:22.995 WARNING (MainThread) [homeassistant.util.loop] Detected blocking call to open with args ('/usr/local/hass/instance-2/lib/python3.12/site-packages/babel/locale-data/root.dat', 'rb') inside the event loop by custom integration 'afvalinfo' at custom_components/afvalinfo/sensor.py, line 369: locale_date = format_date( (offender: /usr/local/hass/instance-2/lib/python3.12/site-packages/babel/localedata.py, line 123: with open(filename, 'rb') as fileobj:), please create a bug report at https://github.com/heyajohnny/afvalinfo/issues
For developers, please see https://developers.home-assistant.io/docs/asyncio_blocking_operations/#open
Traceback (most recent call last):
  File "/usr/local/hass/instance-2/bin/hass", line 8, in <module>
    sys.exit(main())
  File "/usr/local/hass/instance-2/lib/python3.12/site-packages/homeassistant/__main__.py", line 209, in main
    exit_code = runner.run(runtime_conf)
  File "/usr/local/hass/instance-2/lib/python3.12/site-packages/homeassistant/runner.py", line 189, in run
    return loop.run_until_complete(setup_and_run_hass(runtime_config))
  File "/usr/lib/python3.12/asyncio/base_events.py", line 672, in run_until_complete
    self.run_forever()
  File "/usr/lib/python3.12/asyncio/base_events.py", line 639, in run_forever
    self._run_once()
  File "/usr/lib/python3.12/asyncio/base_events.py", line 1985, in _run_once
    handle._run()
  File "/usr/lib/python3.12/asyncio/events.py", line 88, in _run
    self._context.run(self._callback, *self._args)
  File "/usr/local/hass/instance-2/lib/python3.12/site-packages/homeassistant/helpers/entity_platform.py", line 675, in _async_handle_interval_callback
    self.config_entry.async_create_background_task(
  File "/usr/local/hass/instance-2/lib/python3.12/site-packages/homeassistant/config_entries.py", line 1182, in async_create_background_task
    task = hass.async_create_background_task(target, name, eager_start)
  File "/usr/local/hass/instance-2/lib/python3.12/site-packages/homeassistant/core.py", line 861, in async_create_background_task
    task = create_eager_task(target, name=name, loop=self.loop)
  File "/usr/local/hass/instance-2/lib/python3.12/site-packages/homeassistant/util/async_.py", line 45, in create_eager_task
    return Task(coro, loop=loop, name=name, eager_start=True)
  File "/usr/local/hass/instance-2/lib/python3.12/site-packages/homeassistant/helpers/entity_platform.py", line 1041, in _async_update_entity_states
    create_eager_task(
  File "/usr/local/hass/instance-2/lib/python3.12/site-packages/homeassistant/util/async_.py", line 45, in create_eager_task
    return Task(coro, loop=loop, name=name, eager_start=True)
  File "/usr/local/hass/instance-2/lib/python3.12/site-packages/homeassistant/helpers/entity.py", line 942, in async_update_ha_state
    await self.async_device_update()
  File "/usr/local/hass/instance-2/lib/python3.12/site-packages/homeassistant/helpers/entity.py", line 1300, in async_device_update
    await self.async_update()
  File "/home/hass/.homeassistant/custom_components/afvalinfo/sensor.py", line 369, in async_update
    locale_date = format_date(
heyajohnny commented 2 days ago

I reproduced it... It indeed had something to do with the date (your custom date format). It should be fixed in v2.1.4. Please let me know if the newest version fixes this issue

PuckStar commented 1 day ago

I reproduced it... It indeed had something to do with the date (your custom date format). It should be fixed in v2.1.4. Please let me know if the newest version fixes this issue

Yes it's fixed for me now. Thanks!

heyajohnny commented 19 hours ago

Then it's probably fixed. I'm closing the issue