franc6 / ics_calendar

Provides an ICS (icalendar) platform for the Home Assistant calendar
Apache License 2.0
128 stars 19 forks source link

Detected blocking call to open inside the event loop #139

Open Justin991q opened 1 week ago

Justin991q commented 1 week ago

I am getting a lot of errors about a blocking loop event, which is spamming the Home-Assistant logs with a lot of log entries. I am Home-Assistant 2024.6.3 and ICS Calendar version 4.2.0.

https://github.com/franc6/ics_calendar/blob/4.2.0/custom_components/ics_calendar/parsers/parser_rie.py#L32

2024-06-20 09:59:25.985 WARNING (MainThread) [homeassistant.util.loop] Detected blocking call to open inside the event loop by custom integration 'ics_calendar' at custom_components/ics_calendar/parsers/parser_rie.py, line 32: self._calendar = Calendar.from_ical(content) (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/franc6/ics_calendar/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 210, 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/calendar/__init__.py", line 660, in get
    calendar_event_list = await entity.async_get_events(
  File "/config/custom_components/ics_calendar/calendar.py", line 173, in async_get_events
    return await self.data.async_get_events(hass, start_date, end_date)
  File "/config/custom_components/ics_calendar/calendar.py", line 264, in async_get_events
    self.parser.set_content(self._calendar_data.get())
  File "/config/custom_components/ics_calendar/parsers/parser_rie.py", line 32, in set_content
    self._calendar = Calendar.from_ical(content)
franc6 commented 1 week ago

Thanks for the report. I’ll have to see if there’s a way around how pytz is used or if there’s a better solution.

latetedemelon commented 4 days ago

@franc6 - I came here to report the same. Please let me know if I can assist with info, logs, testing etc.