pnbruckner/ha-sun2

[2024.6.0b0]: Detected blocking call to open inside the event loop by custom integration 'sun2'

Closed this issue · 8 comments

Log warning in core-2024.6.0b0:

Logger: homeassistant.util.loop
Source: util/loop.py:81
First occurred: 11:50:42 AM (665 occurrences)
Last logged: 11:51:39 AM

Detected blocking call to open inside the event loop by custom integration 'sun2' at custom_components/sun2/helpers.py, line 369: return getattr(loc, event.split("_")[1])(date_or_dttm) (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/pnbruckner/ha-sun2/issues

Thanks. Didn't realize pytz did that. I'll fix it.

Oh, wait, my integration doesn't use pytz, at least not directly. It uses the astral package, which HA does also (for the sun integration, and sun triggers), and astral must use pytz, either directly or indirectly. I wonder how HA deals with that...

I can't see where HA is dealing with this. Not sure what I can do about this.

@bdraco, hope you don't mind me tagging you. Any ideas?

Thanks! I'll probably have to make changes accordingly.

I also just discovered that HA's built-in code that uses the astral package (probably) always calls functions with "local=False", whereas my integration leaves that out and so uses the default of "local=True". That causes astral's functions to make calls into pytz (2.2 still used pytz as opposed to zoneinfo which I think it started using in 3.0) that ultimately will do file I/O.

@krazos, please let me know if version 3.3.2 fixes the problem for you.

Thanks, @pnbruckner, for jumping on this fix. So far so good on v3.3.2!