rt400 / Jewish-Sabbaths-Holidays

Jewish Shabbat Yomtov and Holidays times and event
9 stars 2 forks source link

Warning in logs #24

Open bru73f0rc3 opened 1 month ago

bru73f0rc3 commented 1 month ago

Shortly after startup i get the following:

WARNING (MainThread) [homeassistant.util.loop] Detected blocking call to open with args ('/usr/local/lib/python3.12/site-packages/pytz/zoneinfo/Africa/Abidjan', 'rb') inside the event loop by custom integration 'hebcal' at custom_components/hebcal/sensor.py, line 516: return utc_dt.replace(tzinfo=datetime.timezone.utc).astimezone(tz=pytz.timezone(timezone)) (offender: /usr/local/lib/python3.12/site-packages/pytz/__init__.py, line 108: return open(filename, 'rb')), please create a bug report at https://github.com/rt400/Jewish-Sabbaths-Holidays/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 189, 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.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/hebcal/sensor.py", line 228, in async_update
    await self.create_db_file()
  File "/config/custom_components/hebcal/sensor.py", line 286, in create_db_file
    await self.filter_db(temp_db["items"], "new")
  File "/config/custom_components/hebcal/sensor.py", line 360, in filter_db
    extract_data["start"] = self.sunset_time(extract_data["date"], -1)
  File "/config/custom_components/hebcal/sensor.py", line 488, in sunset_time
    sunset = self.utc_to_local(data, str(self._timezone))
  File "/config/custom_components/hebcal/sensor.py", line 516, in utc_to_local
    return utc_dt.replace(tzinfo=datetime.timezone.utc).astimezone(tz=pytz.timezone(timezone))

Everything seems to be working fine except for the warning. installed via hacs, running latest, and latest hassOS with latest hass core.

rt400 commented 1 month ago

try to restart your HA and see i the warning came again. on my HA i didn't see it

bru73f0rc3 commented 1 month ago

Yes, I see it after restart and after upgrade. Started off with a clean install of hassOS 2024.9, upgraded to 2024.10 and 2024.10.1. It's a pretty clean setup for now. Let me know if there's any data I can grab for you beyond the log.

rt400 commented 1 month ago

Yes, I see it after restart and after upgrade. Started off with a clean install of hassOS 2024.9, upgraded to 2024.10 and 2024.10.1. It's a pretty clean setup for now. Let me know if there's any data I can grab for you beyond the log.

which country you use? or timezone ?

rt400 commented 1 month ago

@bru73f0rc3 if you have access to sensor.py then try to copy and paste from this link : https://paste.ofcode.org/pyFHRL5ELRq4X54RJhvgYK and make restart to HA and let me know if the warning still appear..

bru73f0rc3 commented 1 month ago

With the new sensor.py

WARNING (MainThread) [homeassistant.util.loop] Detected blocking call to open with args ('/usr/local/lib/python3.12/site-packages/pytz/zoneinfo/Africa/Abidjan', 'rb') inside the event loop by custom integration 'hebcal' at custom_components/hebcal/sensor.py, line 524: self.local_timezone = pytz.timezone(str(self._timezone)) (offender: /usr/local/lib/python3.12/site-packages/pytz/__init__.py, line 108: return open(filename, 'rb')), please create a bug report at https://github.com/rt400/Jewish-Sabbaths-Holidays/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 189, 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 682, in _async_handle_interval_callback
    self.hass.async_create_background_task(
  File "/usr/src/homeassistant/homeassistant/core.py", line 861, in async_create_background_task
    task = create_eager_task(target, name=name, loop=self.loop)
  File "/usr/src/homeassistant/homeassistant/util/async_.py", line 45, in create_eager_task
    return Task(coro, loop=loop, name=name, eager_start=True)
  File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 1041, in _async_update_entity_states
    create_eager_task(
  File "/usr/src/homeassistant/homeassistant/util/async_.py", line 45, 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/hebcal/sensor.py", line 230, in async_update
    await self.create_db_file()
  File "/config/custom_components/hebcal/sensor.py", line 261, in create_db_file
    await self.set_local_timezone()
  File "/config/custom_components/hebcal/sensor.py", line 524, in set_local_timezone
    self.local_timezone = pytz.timezone(str(self._timezone))

Feel free to add prints or whatever will help and i'll get back to you with results.

rt400 commented 1 month ago

@bru73f0rc3 try this one : https://paste.ofcode.org/Rm74DfnmRCGmBdfRRvb6sL and let me know...

bru73f0rc3 commented 1 month ago

Fix looks good, tried a couple of restarts and moving back to the original to make sure the issue reproduces on demand, it does on the original, no errors on the fixed 2.5.1 version. I'll keep an eye open but i doubt anything will popup as it started producing the warnings 30s after start on the original and it's been clean now for 30m.

Thanks for fixing it! :)

rt400 commented 1 month ago

Good to know... i will upload this fix to the git later. let me know if the error will popup again.