custom-components / nordpool

This component allows you to pull in the energy prices into Home-Assistant.
470 stars 111 forks source link

Detecting a blocking call #398

Closed marinus61 closed 2 months ago

marinus61 commented 2 months ago

I get the following warning, and it asks me to make a bug report

Source: util/loop.py:136
First occurred: 09:46:28 (3 occurrences)
Last logged: 10:05:39

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 'nordpool' at custom_components/nordpool/__init__.py, line 158: tz=timezone("Europe/Stockholm"), (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/custom-components/nordpool/issues 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 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 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/src/homeassistant/homeassistant/setup.py", line 165, in async_setup_component result = await _async_setup_component(hass, domain, config) File "/usr/src/homeassistant/homeassistant/setup.py", line 416, in _async_setup_component result = await task File "/config/custom_components/nordpool/__init__.py", line 176, in async_setup return await _dry_setup(hass, config) File "/config/custom_components/nordpool/__init__.py", line 158, in _dry_setup tz=timezone("Europe/Stockholm"),
Detected blocking call to open with args ('/usr/share/zoneinfo/Europe/Stockholm', 'rb') inside the event loop by custom integration 'nordpool' at custom_components/nordpool/aio_price.py, line 110: zone = tz.gettz(zone) (offender: /usr/local/lib/python3.12/site-packages/dateutil/tz/tz.py, line 464: fileobj = open(fileobj, 'rb')), please create a bug report at https://github.com/custom-components/nordpool/issues 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 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 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/src/homeassistant/homeassistant/helpers/entity_platform.py", line 647, in async_add_entities await add_func(coros, entities, timeout) File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 598, in _async_add_entities await coro File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 912, in _async_add_entity await entity.add_to_platform_finish() File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 1365, in add_to_platform_finish await self.async_added_to_hass() File "/config/custom_components/nordpool/sensor.py", line 518, in async_added_to_hass await self.handle_new_hr() File "/config/custom_components/nordpool/sensor.py", line 480, in handle_new_hr today = await self._api.today(self._area, self._currency) File "/config/custom_components/nordpool/__init__.py", line 110, in today return await self._someday(area, currency, "today") File "/config/custom_components/nordpool/__init__.py", line 99, in _someday await self.update_today(None) File "/config/custom_components/nordpool/__init__.py", line 80, in update_today await self._update("today") File "/config/custom_components/nordpool/__init__.py", line 73, in _update data = await spot.hourly(end_date=dt) File "/config/custom_components/nordpool/aio_price.py", line 228, in hourly return await self.fetch(self.HOURLY, end_date, areas) File "/usr/local/lib/python3.12/site-packages/backoff/_async.py", line 151, in retry ret = await target(*args, **kwargs) File "/config/custom_components/nordpool/aio_price.py", line 222, in fetch return join_result_for_correct_time(raw, end_date) File "/config/custom_components/nordpool/aio_price.py", line 110, in join_result_for_correct_time zone = tz.gettz(zone)
Detected blocking call to open with args ('/config/custom_components/hacs/data_client.py', 'wb') inside the event loop by custom integration 'hacs' at custom_components/hacs/repositories/base.py, line 600: ? (offender: /usr/local/lib/python3.12/zipfile/__init__.py, line 1801: open(targetpath, "wb") as target:), please create a bug report at https://github.com/hacs/integration/issues 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 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 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/src/homeassistant/homeassistant/components/websocket_api/decorators.py", line 28, in _handle_async_response await func(hass, connection, msg) File "/config/custom_components/hacs/websocket/repository.py", line 234, in hacs_repository_download File "/config/custom_components/hacs/repositories/base.py", line 893, in async_install File "/config/custom_components/hacs/repositories/base.py", line 975, in async_install_repository File "/config/custom_components/hacs/repositories/base.py", line 566, in download_zip_files File "/config/custom_components/hacs/repositories/base.py", line 600, in async_download_zip_file```

## Version of the custom_component
00.14

## Homeassistant version
Core
2024.8.3
Supervisor
2024.08.0
Operating System
13.0
Frontend
20240809.0

## Configuration

```yaml

Add your configuration here.

Describe the bug

A clear and concise description of what the bug is.

Debug log


Add your logs here.
Hellowlol commented 2 months ago

Please try the new prelease.

KennethLavrsen commented 2 months ago

I installed the beta and I still see this 0.0.15b1 which is the latest in HACS

I still see this blocking call. Why did you close the bug? You do not see it yourself?

2024-09-05 16:46:22.332 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 'nordpool' at custom_components/nordpool/misc.py, line 53: return d.astimezone(timezone("Europe/Stockholm")) (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/custom-components/nordpool/issues
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/src/homeassistant/homeassistant/helpers/entity_component.py", line 308, in async_setup_platform
await self._platforms[key].async_setup(platform_config, discovery_info)
File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 298, in async_setup
await self._async_setup_platform(async_create_setup_awaitable)
File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 358, in _async_setup_platform
awaitable = create_eager_task(awaitable, loop=hass.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 "/config/custom_components/nordpool/sensor.py", line 124, in async_setup_platform
_dry_setup(hass, config, add_devices)
File "/config/custom_components/nordpool/sensor.py", line 120, in _dry_setup
add_devices([sensor])
File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 495, in _async_schedule_add_entities
task = self.hass.async_create_task_internal(
File "/usr/src/homeassistant/homeassistant/core.py", line 829, in async_create_task_internal
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/helpers/entity_platform.py", line 644, in async_add_entities
await add_func(coros, entities, timeout)
File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 595, in _async_add_entities
await coro
File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 909, in _async_add_entity
await entity.add_to_platform_finish()
File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 1365, in add_to_platform_finish
await self.async_added_to_hass()
File "/config/custom_components/nordpool/sensor.py", line 516, in async_added_to_hass
await self.handle_new_hr()
File "/config/custom_components/nordpool/sensor.py", line 483, in handle_new_hr
if self._data_tomorrow is SENTINEL and stock(now) >= stock(now).replace(
File "/config/custom_components/nordpool/misc.py", line 53, in stock
return d.astimezone(timezone("Europe/Stockholm"))