core icon indicating copy to clipboard operation
core copied to clipboard

Detected blocking call to load_verify_locations inside the event loop by integration 'smart_meter_texas'

Open CorruptComputer opened this issue 1 year ago • 1 comments

The problem

Saw this in the logs of my home assistant instance, didn't see an open issue about this so figured I should open one:

Logger: homeassistant.util.loop
Source: util/loop.py:136
First occurred: 4:39:14 AM (2 occurrences)
Last logged: 4:39:14 AM


2024-10-05 04:39:14.613 WARNING (MainThread) [homeassistant.util.loop] Detected blocking call to load_verify_locations with args (<ssl.SSLContext object at 0x7feeb2f7aad0>, None, '/usr/local/lib/python3.12/site-packages/certifi/cacert.pem', None) inside the event loop by integration 'smart_meter_texas' at homeassistant/components/smart_meter_texas/__init__.py, line 42: ssl_context = await client_ssl_context.get_ssl_context() (offender: /usr/local/lib/python3.12/ssl.py, line 708: context.load_verify_locations(cafile, capath, cadata)), please create a bug report at https://github.com/home-assistant/core/issues?q=is%3Aopen+is%3Aissue+label%3A%22integration%3A+smart_meter_texas%22
For developers, please see https://developers.home-assistant.io/docs/asyncio_blocking_operations/#load_verify_locations
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/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 "/usr/src/homeassistant/homeassistant/components/smart_meter_texas/__init__.py", line 42, in async_setup_entry ssl_context = await client_ssl_context.get_ssl_context()

2024-10-05 04:39:14.666 WARNING (MainThread) [homeassistant.util.loop] Detected blocking call to load_verify_locations with args (<ssl.SSLContext object at 0x7feeb2f7aad0>,) inside the event loop by integration 'smart_meter_texas' at homeassistant/components/smart_meter_texas/__init__.py, line 42: ssl_context = await client_ssl_context.get_ssl_context() (offender: /usr/local/lib/python3.12/site-packages/smart_meter_texas/__init__.py, line 422: ssl_context.load_verify_locations(), please create a bug report at https://github.com/home-assistant/core/issues?q=is%3Aopen+is%3Aissue+label%3A%22integration%3A+smart_meter_texas%22
For developers, please see https://developers.home-assistant.io/docs/asyncio_blocking_operations/#load_verify_locations
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/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 "/usr/src/homeassistant/homeassistant/components/smart_meter_texas/__init__.py", line 42, in async_setup_entry ssl_context = await client_ssl_context.get_ssl_context()

Integration still seems to be working fine though.

What version of Home Assistant Core has the issue?

core-2024.10.1

What was the last working version of Home Assistant Core?

unknown

What type of installation are you running?

Home Assistant OS

Integration causing the issue

Smart Meter Texas

Link to integration documentation on our website

https://www.home-assistant.io/integrations/smart_meter_texas

Diagnostics information

home-assistant_smart_meter_texas_2024-10-05T10-04-53.341Z.log

Example YAML snippet

n/a

Anything in the logs that might be useful for us?

n/a

Additional information

n/a

CorruptComputer avatar Oct 05 '24 09:10 CorruptComputer

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

Code owner commands

Code owners of smart_meter_texas 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 smart_meter_texas 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)


smart_meter_texas documentation smart_meter_texas source (message by IssueLinks)

home-assistant[bot] avatar Oct 05 '24 09:10 home-assistant[bot]

Same here.

mstarks01 avatar Oct 18 '24 02:10 mstarks01

@grahamwetzler anything I can do to help? Additional debug logs, perhaps?

mstarks01 avatar Nov 12 '24 17:11 mstarks01

Just an FYI, Smart Meter Texas changed their API access rules and their endpoints. To even gain access to their APIs you have to have a static IP and a SSL key. Even if you have the ability to create / obtain these I believe the endpoints are different now than they were when this was working, so this code base would probably need to be updated to reflect those changes.

stottsjr avatar Dec 05 '24 15:12 stottsjr

I'm also seeing this in my logs.

I just rebuilt my HA instance from the ground up, new hardware, removed all unessential add-ons and integrations, cleaned up all config, automation, scripts, etc. I assume that this error has been in my logs for the past 4 months but the logs were so cluttered with other issues that crept in over the past 4 years that I'd missed it.

The comment about API and endpoints seems unrelated:

  • the integration is working for me and has since early last year after previous issues related to the API and endpoints had been resolved
  • the issue seems related to how the integration handles setting SSL context, that it blocks on identifying certs in code that is intended to be async

I've noticed that there are many other core integrations that have issues reported, both open and closed, related to this same type of blocking issue. For the maintainers, perhaps the answer lies in how this was addressed in other integrations?

That said, I did notice that the actual definition of code at the heart of this issue, ClientSSLContext, is actually in the library smart_meter_texas that this integration is dependent on. A fix may involve changes in both the integration and library.

NateEaton avatar Feb 06 '25 04:02 NateEaton

There hasn't been any activity on this issue recently. Due to the high number of incoming GitHub notifications, we have to clean some of the old issues, as many of them have already been resolved with the latest updates. Please make sure to update to the latest Home Assistant version and check if that solves the issue. Let us know if that works for you by adding a comment 👍 This issue has now been marked as stale and will be closed if no further activity occurs. Thank you for your contributions.

I don't use this integration anymore so I'm not 100% sure if its been fixed, but this may have been fixed by https://github.com/home-assistant/core/pull/140694

That PR seems to change the exact line that was being complained about in this log:

at homeassistant/components/smart_meter_texas/__init__.py, line 42

CorruptComputer avatar May 07 '25 22:05 CorruptComputer

There hasn't been any activity on this issue recently. Due to the high number of incoming GitHub notifications, we have to clean some of the old issues, as many of them have already been resolved with the latest updates. Please make sure to update to the latest Home Assistant version and check if that solves the issue. Let us know if that works for you by adding a comment 👍 This issue has now been marked as stale and will be closed if no further activity occurs. Thank you for your contributions.