-
Notifications
You must be signed in to change notification settings - Fork 289
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
WARNING: Detected blocking call to load_verify_locations with args (<ssl.SSLContext object at 0x7f155d069e50>,) inside the event loop by custom integration 'alexa_media #2504
Comments
So notifications fail again? |
Same problem |
How does this affect Alexa Media Player?How does this affect Alexa Media Player? |
I am encountering this error during initial configuration of the integration and therefore it cannot be added. My information is the same as above, except for the Amazon domain, which for me is amazon.com |
is it possible to fix it? |
Experiencing the same issue, it started occurring since the latest update to the integration - before this point the error was not experienced. |
!!! IT'S JUST A WARNING !!!
Possibly, but I do not know how, or where (alexa_media or alexpy) It's all outlined in Blocking operations with asyncio but it's all pseudo code and trying to figure out exactly what should be changed and how is beyond my current skill level. |
FWIW, the Core integration Netdata has triggered the same WARNING... |
The Core integration
Changes were required in both the HA Core integration I think I see how changes in As for |
You are likely to need to wrap the call to the offending function with 'await hass.async_add_executor_job', which obviously nee ds to be done from an async function. This will push it outside the executor thread. If the function call was 'blockingfunction(param1, param2)' this would get changed to 'await hass.async_add_executor_job(blockingfunction, param1, param2). You will need access to hass somewhere, but it's usually hanging around somewhere. |
same problem for me. |
I've tried every which way from Sunday that I can think of to implement that here:
This is the function in
I think this is one of the blocking calls within try:
async with aiofiles.open(cookiefile, "rb") as myfile:
cookies = pickle.loads(await myfile.read())
if self._debug:
_LOGGER.debug(
"Pickled cookie loaded: %s %s", type(cookies), cookies
) |
I’ll try to take a look when I get a chance. It’ll make a change from adding testing to an integration I created. |
Thanks but I already have all the logs. |
Looking at the original error, lines 340, 360 and 875 need wrapping. But at least one has a keyword argument, so it may need a partial well. At line 360 there is an await embedded as a parameter (seems weird to me). I’d probably break it apart, create the cookie on one line then pass it as a parameter on the next. It would make it easier to identify the issue. On my phone at the moment, but may look on a big screen in a short while. |
Just had a go at solving the one at line 343. As you say seems easier said than done since it seems like it goes from sync call to AlexaLogin class which then initiates an async call. I'm not knowledgeable enough, I'll do some digging, because I've used hass.async_add_executor_job I think it has moved it outside the loop, and then when it trues to go async inside AlexaLogin it can't find the loop to start a session from. Edit: I think AlexaLogin needs to be modified to allow a session to be passed in, which looking at the code would be a fairly easy change. Probably needs a discussion with @alandtse. |
The integration has become unusable and useless... the entities are shown as offline and not working anymore. This bug + the bug related to the reauth issue are making this custom component not working anymore. Any plan to fix it? |
@stefano This issue is not a bug! It is a warning only!
Is there a "plan"? No, there's no one at the ship's helm! There's only users like you, me, @RogerSelwyn, etc. |
Is this why I suddenly have busted HA devices inside of Alexa? All the devices I expose through home assistant to Alexa are showing as unreachable suddenly. And I get the same warning in logs. Can't use my voice commands hardly at all |
@kmil4,
|
I take this opportunity to thank you for all the help you have given us, selflessly, and for that time which is surely a lot to make the component work, I thank you from the bottom of my heart. |
Got the same issue. Has been doing this for a while now. |
Analysis by ChatGPT: Here is a summary of the issues that are outside our scope and why we cannot fix them directly: 1. Blocking SSL operations (
|
So now we rely in AI to fix the code? |
So you can do better? Go on! |
I don't know how the code works, if you can teach me the code, I will be glad to fix it. I always take care of bugs of my own code... |
Hi Daniel, Best Regards |
I got the same error message by the custom homematic ip integration by the way. So it looks like a generall issue. (running latest stable version on proxmox) |
+1, Detected blocking call to load_verify_locations with args (<ssl.SSLContext object at 0x7f57e11f50>,) inside the event loop by custom integration 'alexa_media' at custom_components/alexa_media/init.py, line 922: http2 = HTTP2EchoClient( (offender: /usr/local/lib/python3.12/site-packages/httpx/_config.py, line 149: context.load_verify_locations(cafile=cafile)), please create a bug report at https://github.com/alandtse/alexa_media_player/issues |
I repeat..."Detected blocking call to load_verify_locations" is a WARNING ONLY and has NOTHING WHATSOEVER to do with any issues you might be having! DO NOT POST YOUR ISSUES HERE! |
So why this component became buggy and it's not working anymore. It requires continuous reauthentication... what's the error related to this and when will it be fixed? |
It started back in June with web browsers new partitioned cookies structure.
My installation is fine - no re-auth required.
You have to analyze your logs.
Your guess is as good as mine, maybe never. |
I am able to login after supervisor update followed by Create Account option even though account exists able to restore the integration. Thanks all for the feedback and suggestion. |
There are pending merge requests in alexapy to address the "WARNING: Detected blocking call" messages: |
The problem seems resolved with AMP v4.13.5 |
Describe the bug
This is not a bug!
The warning messages should be addressed though so as to not impact performance in the HA event loop.
To Reproduce
HA 2024.9.x now detects blocking calls (which have always been this way)
Expected behavior
No warning messages
System details
const.py
or HA startup log): 4.12.11pip show alexapy
in homeasssistant container or HA startup log): 1.28.2Debug Logs (alexa_media & alexapy)
2024-09-04 19:37:06.401 WARNING (MainThread) [homeassistant.util.loop] Detected blocking call to load_verify_locations with args (<ssl.SSLContext object at 0x7f155dedfd50>, '/usr/local/lib/python3.12/site-packages/certifi/cacert.pem', None, None) inside the event loop by custom integration 'alexa_media' at custom_components/alexa_media/init.py, line 340: AlexaLogin( (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/alandtse/alexa_media_player/issues
For developers, please see https://developers.home-assistant.io/docs/asyncio_blocking_operations/#load_verify_locations
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 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/setup.py", line 165, in async_setup_component
result = await _async_setup_component(hass, domain, config)
File "/usr/src/homeassistant/homeassistant/setup.py", line 461, in async_setup_component
await asyncio.gather(
File "/usr/src/homeassistant/homeassistant/setup.py", line 463, in
create_eager_task(
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/config_entries.py", line 752, in async_setup_locked
await self.async_setup(hass, integration=integration)
File "/usr/src/homeassistant/homeassistant/config_entries.py", line 604, in async_setup
result = await component.async_setup_entry(hass, self)
File "/config/custom_components/alexa_media/init.py", line 340, in async_setup_entry
AlexaLogin(
2024-09-04 19:37:06.627 WARNING (MainThread) [homeassistant.util.loop] Detected blocking call to open with args (PosixPath('/config/.storage/[email protected]'),) inside the event loop by custom integration 'alexa_media' at custom_components/alexa_media/init.py, line 360: await login.login(cookies=await login.load_cookie()) (offender: /usr/local/lib/python3.12/site-packages/aiohttp/cookiejar.py, line 118: with file_path.open(mode="rb") as f:), please create a bug report at https://github.com/alandtse/alexa_media_player/issues
For developers, please see https://developers.home-assistant.io/docs/asyncio_blocking_operations/#open
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 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 752, in async_setup_locked
await self.async_setup(hass, integration=integration)
File "/usr/src/homeassistant/homeassistant/config_entries.py", line 604, in async_setup
result = await component.async_setup_entry(hass, self)
File "/config/custom_components/alexa_media/init.py", line 360, in async_setup_entry
await login.login(cookies=await login.load_cookie())
2024-09-04 19:37:08.988 WARNING (MainThread) [homeassistant.util.loop] Detected blocking call to open with args (PosixPath('/config/.storage/[email protected]'),) inside the event loop by custom integration 'alexa_media' at custom_components/alexa_media/init.py, line 360: await login.login(cookies=await login.load_cookie()) (offender: /usr/local/lib/python3.12/site-packages/aiohttp/cookiejar.py, line 113: with file_path.open(mode="wb") as f:), please create a bug report at https://github.com/alandtse/alexa_media_player/issues
For developers, please see https://developers.home-assistant.io/docs/asyncio_blocking_operations/#open
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 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 752, in async_setup_locked
await self.async_setup(hass, integration=integration)
File "/usr/src/homeassistant/homeassistant/config_entries.py", line 604, in async_setup
result = await component.async_setup_entry(hass, self)
File "/config/custom_components/alexa_media/init.py", line 360, in async_setup_entry
await login.login(cookies=await login.load_cookie())
2024-09-04 19:37:09.071 WARNING (MainThread) [homeassistant.util.loop] Detected blocking call to load_verify_locations with args (<ssl.SSLContext object at 0x7f155d069e50>,) inside the event loop by custom integration 'alexa_media' at custom_components/alexa_media/init.py, line 875: http2 = HTTP2EchoClient( (offender: /usr/local/lib/python3.12/site-packages/httpx/_config.py, line 147: context.load_verify_locations(cafile=cafile)), please create a bug report at https://github.com/alandtse/alexa_media_player/issues
For developers, please see https://developers.home-assistant.io/docs/asyncio_blocking_operations/#load_verify_locations
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 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 752, in async_setup_locked
await self.async_setup(hass, integration=integration)
File "/usr/src/homeassistant/homeassistant/config_entries.py", line 604, in async_setup
result = await component.async_setup_entry(hass, self)
File "/config/custom_components/alexa_media/init.py", line 362, in async_setup_entry
await setup_alexa(hass, config_entry, login)
File "/config/custom_components/alexa_media/init.py", line 1265, in setup_alexa
await http2_connect()
File "/config/custom_components/alexa_media/init.py", line 875, in http2_connect
http2 = HTTP2EchoClient(
Additional context
The text was updated successfully, but these errors were encountered: