blakeblackshear / frigate-hass-integration

Frigate integration for Home Assistant
MIT License
726 stars 114 forks source link

Detected blocking call to open inside the event loop #688

Open SukramJ opened 3 months ago

SukramJ commented 3 months ago

Version of the custom_component

5.2

Configuration

Should not be necessary in this case.

Add your logs here.

2024-06-12 20:30:05.309 WARNING (MainThread) [homeassistant.util.loop] Detected blocking call to open inside the event loop by custom integration 'frigate' at custom_components/frigate/media_source.py, line 469: ) - (dt.datetime.now(pytz.timezone(timezone)).utcoffset() or dt.timedelta()) (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/blakeblackshear/frigate-hass-integration/issues

Describe the bug

Found this warning in the logs. Also found a possibly related entry in the HA dev blog: https://developers.home-assistant.io/blog/2024/05/19/fix_zoneinfo_blocking_io/

Debug log

Debug log should not be necessary in this case.

seancmalloy commented 3 months ago

I am getting this too, cpu runs extremely high for awhile. Hopefully it will be addressed. Update your post if you resolve it yourself.

h3x1e commented 3 months ago

Yeah getting the same.

Here's my log.


Source: util/loop.py:84
First occurred: 20 June 2024 at 22:08:57 (597 occurrences)
Last logged: 20 June 2024 at 22:08:59

Detected blocking call to open inside the event loop by custom integration 'frigate' at custom_components/frigate/media_source.py, line 469: ) - (dt.datetime.now(pytz.timezone(timezone)).utcoffset() or dt.timedelta()) (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/blakeblackshear/frigate-hass-integration/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/local/lib/python3.12/site-packages/aiohttp/web_protocol.py", line 452, in _handle_request resp = await request_handler(request) File "/usr/local/lib/python3.12/site-packages/aiohttp/web_app.py", line 543, in _handle resp = await handler(request) File "/usr/local/lib/python3.12/site-packages/aiohttp/web_middlewares.py", line 114, in impl return await handler(request) File "/usr/src/homeassistant/homeassistant/components/http/security_filter.py", line 92, in security_filter_middleware return await handler(request) File "/usr/src/homeassistant/homeassistant/components/http/forwarded.py", line 83, in forwarded_middleware return await handler(request) File "/usr/src/homeassistant/homeassistant/components/http/request_context.py", line 26, in request_context_middleware return await handler(request) File "/usr/src/homeassistant/homeassistant/components/http/ban.py", line 85, in ban_middleware return await handler(request) File "/usr/src/homeassistant/homeassistant/components/http/auth.py", line 242, in auth_middleware return await handler(request) File "/usr/src/homeassistant/homeassistant/components/http/headers.py", line 32, in headers_middleware response = await handler(request) File "/usr/src/homeassistant/homeassistant/helpers/http.py", line 73, in handle result = await handler(request, **request.match_info) File "/usr/src/homeassistant/homeassistant/components/websocket_api/http.py", line 54, in get return await WebSocketHandler(request.app[KEY_HASS], request).async_handle() File "/usr/src/homeassistant/homeassistant/components/websocket_api/http.py", line 438, in async_handle async_handle_str(command_msg_data) File "/usr/src/homeassistant/homeassistant/components/websocket_api/connection.py", line 229, in async_handle handler(self.hass, self, schema(msg)) File "/usr/src/homeassistant/homeassistant/components/websocket_api/decorators.py", line 46, in schedule_handler hass.async_create_background_task( File "/usr/src/homeassistant/homeassistant/core.py", line 860, 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/components/websocket_api/decorators.py", line 27, in _handle_async_response await func(hass, connection, msg) File "/usr/src/homeassistant/homeassistant/components/media_source/__init__.py", line 209, in websocket_resolve_media media = await async_resolve_media(hass, msg["media_content_id"], None) File "/usr/src/homeassistant/homeassistant/components/media_source/__init__.py", line 172, in async_resolve_media return await item.async_resolve() File "/usr/src/homeassistant/homeassistant/components/media_source/models.py", line 84, in async_resolve return await self.async_media_source().async_resolve_media(self) File "/config/custom_components/frigate/media_source.py", line 575, in async_resolve_media server_path = identifier.get_integration_proxy_path( File "/config/custom_components/frigate/media_source.py", line 469, in get_integration_proxy_path ) - (dt.datetime.now(pytz.timezone(timezone)).utcoffset() or dt.timedelta()) ```
github-actions[bot] commented 2 months ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

SukramJ commented 2 months ago

Still valid

github-actions[bot] commented 1 month ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

def1149 commented 2 weeks ago

Seeing similar. Running Frigate 0.14.1 HAOS 2024.9.2 Frigate Integration 5.4.0

2024-09-18 14:37:44.465 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 'frigate' at custom_components/frigate/media_source.py, line 469: ) - (dt.datetime.now(pytz.timezone(timezone)).utcoffset() or dt.timedelta()) (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/blakeblackshear/frigate-hass-integration/issues
bdraco commented 6 days ago

https://developers.home-assistant.io/blog/2024/05/19/fix_zoneinfo_blocking_io?_highlight=aiozoneinfo