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

Toyota Connected Services 2.0.3 - Detected blocking call to open inside the event #271

Open
maestrigia opened this issue Jun 19, 2024 · 7 comments
Labels

Comments

@maestrigia
Copy link

I installed the last Toyota 2.0.3 version from HACS, it failed when I added my Toyota credentials, look below the error message:

Detected blocking call to open inside the event loop by custom integration 'toyota' at custom_components/toyota/init.py, line 56: client = MyT( (offender: /usr/local/lib/python3.12/site-packages/mytoyota/controller.py, line 56: with open(str(CACHE_FILENAME), "r", encoding="utf-8") as f:), please create a bug report at https://github.com/DurgNomis-drol/ha_toyota/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 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 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/config/config_entries.py", line 120, in post await hass.config_entries.async_reload(entry_id) File "/usr/src/homeassistant/homeassistant/config_entries.py", line 1897, in async_reload return await self.async_setup(entry_id, _lock=False) File "/usr/src/homeassistant/homeassistant/config_entries.py", line 1821, in async_setup await entry.async_setup(self.hass) 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/toyota/init.py", line 56, in async_setup_entry client = MyT(

@c4xp
Copy link

c4xp commented Jun 19, 2024

Yep, I stopped by to confirm I have the same issue

@MarcoZ76
Copy link

have the same issue too

@pejotigrek
Copy link

pejotigrek commented Aug 5, 2024

I've got probably similar/connected issue:

Detected blocking call to open with args ('/root/.cache/toyota_credentials_cache_contains_secrets', 'r')

also at custom_components/toyota/__init__.py, line 56, my traceback looks different tho, but in addition I see this link in my log - as a hint, may be useful:
For developers, please see https://developers.home-assistant.io/docs/asyncio_blocking_operations/#open

@ajain-93
Copy link
Contributor

ajain-93 commented Aug 24, 2024

Try updating to version 2.0.5, this should be fixed in the latest version.

@pejotigrek
Copy link

updated to 2.0.5, I've noticed that fuel level is back [it dissapeared few days earlier and I couldn't bring it back no matter what ;)], but still can see some issue similar to the above mentioned, but now it's another line in code. current warning in log:

2024-08-25 20:18:31.729 WARNING (MainThread) [homeassistant.util.loop] Detected blocking call to open with args ('/root/.cache/toyota_credentials_cache_contains_secrets', 'w') inside the event loop by custom integration 'toyota' at custom_components/toyota/__init__.py, line 77: vehicles = await asyncio.wait_for(client.get_vehicles(metric=metric_values), 15) (offender: /usr/local/lib/python3.12/site-packages/mytoyota/controller.py, line 203: with open(str(CACHE_FILENAME), "w", encoding="utf-8") as f:), please create a bug report at https://github.com/DurgNomis-drol/ha_toyota/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/update_coordinator.py", line 258, in _handle_refresh_interval
    await self._async_refresh(log_failures=True, scheduled=True)
  File "/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py", line 354, in _async_refresh
    self.data = await self._async_update_data()
  File "/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py", line 271, in _async_update_data
    return await self.update_method()
  File "/config/custom_components/toyota/__init__.py", line 77, in async_get_vehicle_data
    vehicles = await asyncio.wait_for(client.get_vehicles(metric=metric_values), 15)

@CM000n
Copy link
Collaborator

CM000n commented Aug 27, 2024

This is not really a problem with the ha_toyota custom integration, but rather with the mytoyota Python lib used.
This lib does write (non async) a file with the cached request responses to the file system when it is initialized, which causes a blocking call.

@pejotigrek
Copy link

This is not really a problem with the ha_toyota custom integration, but rather with the mytoyota Python lib used. This lib does write (non async) a file with the cached request responses to the file system when it is initialized, which causes a blocking call.

understood. thanks for clarification

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

6 participants