Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Detected blocking call to open inside the event loop (HA 2024.6) #152

Closed
1 task done
hmmbob opened this issue Jun 1, 2024 · 4 comments · Fixed by #153
Closed
1 task done

Detected blocking call to open inside the event loop (HA 2024.6) #152

hmmbob opened this issue Jun 1, 2024 · 4 comments · Fixed by #153
Labels
bug Something isn't working

Comments

@hmmbob
Copy link
Contributor

hmmbob commented Jun 1, 2024

Did you read the instructions?

The problem

Got a lot of warnings on 2024.6 beta (600+ lines):

Detected blocking call to open inside the event loop by custom integration 'knmi' at custom_components/knmi/coordinator.py, line 90: timezone = pytz.timezone(API_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/golles/ha-knmi/issues

This might be related:
https://developers.home-assistant.io/blog/2024/05/19/fix_zoneinfo_blocking_io/

Integration version

2.1.0

Home Assistant version

core-2024.6.0b4

Python version

3.12.2

Home Assistant log

No response

Diagnostics

No response

Additional information

No response

@hmmbob hmmbob added the bug Something isn't working label Jun 1, 2024
@hmmbob
Copy link
Contributor Author

hmmbob commented Jun 3, 2024

beta 5 geeft nog meer info in de foutmelding:

Detected blocking call to open inside the event loop by custom integration 'knmi' at custom_components/knmi/coordinator.py, line 90: timezone = pytz.timezone(API_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/golles/ha-knmi/issues Traceback (most recent call last): File "", line 198, in _run_module_as_main File "", line 88, in _run_code File "/usr/src/homeassistant/homeassistant/main.py", line 223, in 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 188, 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/src/homeassistant/homeassistant/config_entries.py", line 742, in async_setup_locked await self.async_setup(hass, integration=integration) File "/usr/src/homeassistant/homeassistant/config_entries.py", line 594, in async_setup result = await component.async_setup_entry(hass, self) File "/config/custom_components/knmi/init.py", line 75, in async_setup_entry await hass.config_entries.async_forward_entry_setups(entry, PLATFORMS) File "/usr/src/homeassistant/homeassistant/config_entries.py", line 2032, in async_forward_entry_setups await asyncio.gather( File "/usr/src/homeassistant/homeassistant/config_entries.py", line 2034, in create_eager_task( 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/config_entries.py", line 2081, in _async_forward_entry_setup await entry.async_setup(self.hass, integration=integration) File "/usr/src/homeassistant/homeassistant/config_entries.py", line 594, in async_setup result = await component.async_setup_entry(hass, self) File "/usr/src/homeassistant/homeassistant/components/binary_sensor/init.py", line 234, in async_setup_entry return await component.async_setup_entry(entry) File "/usr/src/homeassistant/homeassistant/helpers/entity_component.py", line 196, in async_setup_entry return await self._platforms[key].async_setup_entry(config_entry) File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 333, in async_setup_entry return await self._async_setup_platform(async_create_setup_awaitable) File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 363, in async_setup_platform awaitable = create_eager_task(awaitable, loop=hass.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 "/config/custom_components/knmi/binary_sensor.py", line 74, in async_setup_entry async_add_entities(entities) File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 515, in async_schedule_add_entities_for_entry task = self.config_entry.async_create_task( File "/usr/src/homeassistant/homeassistant/config_entries.py", line 1134, in async_create_task task = hass.async_create_task_internal( File "/usr/src/homeassistant/homeassistant/core.py", line 828, in async_create_task_internal 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/helpers/entity_platform.py", line 649, in async_add_entities await add_func(coros, entities, timeout) File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 600, in _async_add_entities await coro File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 914, in _async_add_entity await entity.add_to_platform_finish() File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 1355, in add_to_platform_finish self.async_write_ha_state() File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 1000, in async_write_ha_state self._async_write_ha_state() File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 1126, in _async_write_ha_state state, attr, capabilities, shadowed_attr = self.__async_calculate_state() File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 1065, in __async_calculate_state if extra_state_attributes := self.extra_state_attributes: File "/config/custom_components/knmi/binary_sensor.py", line 108, in extra_state_attributes return self.entity_description.attr_fn(self.coordinator) File "/config/custom_components/knmi/binary_sensor.py", line 33, in "timestamp": coordinator.get_value_datetime( File "/config/custom_components/knmi/coordinator.py", line 90, in get_value_datetime timezone = pytz.timezone(API_TIMEZONE)

@golles
Copy link
Owner

golles commented Jun 4, 2024

I saw the blog post when it was published, but I thought it wouldn't affect this component since it is using pytz.timezone which wasn't mentioned. So thank you for reporting beta feedback!

The linked PR has a fix on top of 2024.6.0b6

@golles golles pinned this issue Jun 5, 2024
@golles
Copy link
Owner

golles commented Jun 5, 2024

Made a pre-release 2.2.0-b1 containing the fix

@golles
Copy link
Owner

golles commented Jun 6, 2024

2.2.0 has been released containing a fix for this issue
https://github.com/golles/ha-knmi/releases/tag/2.2.0

@golles golles unpinned this issue Jun 27, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants