home-assistant / core

:house_with_garden: Open source home automation that puts local control and privacy first.
https://www.home-assistant.io
Apache License 2.0
73.49k stars 30.7k forks source link

Detected blocking call to open inside the event loop by integration 'local_todo' #120576

Closed wiedwo closed 1 month ago

wiedwo commented 4 months ago

The problem

2024-06-26 15:37:09.011 WARNING (MainThread) [homeassistant.util.loop] Detected blocking call to open inside the event loop by integration 'local_todo' at homeassistant/components/local_todo/todo.py, line 169: self._new_todo_store().edit(todo.uid, todo) (offender: /usr/local/lib/python3.12/zoneinfo/_tzpath.py, line 137: with open(fpath, "rb") as f:), please create a bug report at https://github.com/home-assistant/core/issues?q=is%3Aopen+is%3Aissue+label%3A%22integration%3A+local_todo%22

What version of Home Assistant Core has the issue?

2024.6.4

What was the last working version of Home Assistant Core?

2024.5.4

What type of installation are you running?

Home Assistant OS

Integration causing the issue

local_todo

Link to integration documentation on our website

No response

Diagnostics information

None

Example YAML snippet

None

Anything in the logs that might be useful for us?

None

Additional information

None

home-assistant[bot] commented 4 months ago

Hey there @allenporter, mind taking a look at this issue as it has been labeled with an integration (local_todo) you are listed as a code owner for? Thanks!

Code owner commands Code owners of `local_todo` can trigger bot actions by commenting: - `@home-assistant close` Closes the issue. - `@home-assistant rename Awesome new title` Renames the issue. - `@home-assistant reopen` Reopen the issue. - `@home-assistant unassign local_todo` Removes the current integration label and assignees on the issue, add the integration domain after the command. - `@home-assistant add-label needs-more-information` Add a label (needs-more-information, problem in dependency, problem in custom component) to the issue. - `@home-assistant remove-label needs-more-information` Remove a label (needs-more-information, problem in dependency, problem in custom component) on the issue.

(message by CodeOwnersMention)


local_todo documentation local_todo source (message by IssueLinks)

allenporter commented 3 months ago

@DemianTinkiel your post is unrelated to this issue. it means your local environment has been corrupted by a custom compoennt.

tomlut commented 1 month ago

This seems to only occur when new todo lists are created. I had not seen this issue before but ceated a new list today which resulted in:

Logger: homeassistant.util.loop
Source: util/loop.py:136
First occurred: 09:13:25 (1 occurrences)
Last logged: 09:13:25

Detected blocking call to open with args (PosixPath('/usr/local/lib/python3.12/site-packages/tzdata/zoneinfo/Australia/Hobart'), 'rb') inside the event loop by integration 'local_todo' at homeassistant/components/local_todo/todo.py, line 169: self._new_todo_store().edit(todo.uid, todo) (offender: /usr/local/lib/python3.12/site-packages/ical/tzif/timezoneinfo.py, line 76: with resources.files(package).joinpath(resource).open("rb") as tzdata_file:), please create a bug report at https://github.com/home-assistant/core/issues?q=is%3Aopen+is%3Aissue+label%3A%22integration%3A+local_todo%22 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/local/lib/python3.12/site-packages/aiohttp/web_protocol.py", line 462, in _handle_request resp = await request_handler(request) File "/usr/local/lib/python3.12/site-packages/aiohttp/web_app.py", line 537, 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 77, 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 55, in get return await WebSocketHandler(request.app[KEY_HASS], request).async_handle() File "/usr/src/homeassistant/homeassistant/components/websocket_api/http.py", line 341, in async_handle await self._async_websocket_command_phase(connection, send_bytes_text) File "/usr/src/homeassistant/homeassistant/components/websocket_api/http.py", line 492, in _async_websocket_command_phase 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 47, in schedule_handler 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/components/websocket_api/decorators.py", line 28, in _handle_async_response await func(hass, connection, msg) File "/usr/src/homeassistant/homeassistant/components/websocket_api/commands.py", line 245, in handle_call_service response = await hass.services.async_call( File "/usr/src/homeassistant/homeassistant/core.py", line 2761, in async_call response_data = await coro File "/usr/src/homeassistant/homeassistant/core.py", line 2804, in _execute_service return await target(service_call) File "/usr/src/homeassistant/homeassistant/helpers/service.py", line 996, in entity_service_call single_response = await _handle_entity_call( File "/usr/src/homeassistant/homeassistant/helpers/service.py", line 1062, in _handle_entity_call task = hass.async_run_hass_job(func, entity, data) File "/usr/src/homeassistant/homeassistant/core.py", line 940, in async_run_hass_job return self._async_add_hass_job(hassjob, *args, background=background) File "/usr/src/homeassistant/homeassistant/core.py", line 755, in _async_add_hass_job task = 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/components/todo/__init__.py", line 507, in _async_update_todo_item await entity.async_update_todo_item(item=TodoItem(**updated_data)) File "/usr/src/homeassistant/homeassistant/components/local_todo/todo.py", line 169, in async_update_todo_item self._new_todo_store().edit(todo.uid, todo)
allenporter commented 1 month ago

In that example i think this https://github.com/allenporter/ical/blob/24bc0e2f21fc23e9ce37d65bc0480cf3401fff53/ical/store.py#L44 is what will need to be made async,