Skip to content

Unblocking creation of SSL context #1469

@patrickvorgers

Description

@patrickvorgers

Describe the bug
PR #1462 provides the ability to preload the caches and thus providing the ability to have it executed off the event loop. After applying this fix to the IDrive e2 backup integration within Home Assistant an issue remains regaring the creation of the ssl_context.load_verify_locations(ca_certs, None, None)) which is still created on the event loop. Can this be resolved so that it is not created on the event loop?

This is related to issue #1199 but more specific because PR #1462 already fixes the biggest part of the issue.

    session = AioSession()
    await hass.async_add_executor_job(session.warm_up_loader_caches, "s3")
    client: S3Client | None = None
    try:
        cm = session.create_client(
            "s3",
            endpoint_url=entry.data[CONF_ENDPOINT_URL],
            aws_secret_access_key=entry.data[CONF_SECRET_ACCESS_KEY],
            aws_access_key_id=entry.data[CONF_ACCESS_KEY_ID],
        )
        # pylint: disable-next=unnecessary-dunder-call
        client = await cm.__aenter__()
        await cast(Any, client).head_bucket(Bucket=entry.data[CONF_BUCKET])
    except ClientError as err:

The SSL issue is triggered in the head_bucket call.

2026-01-20 21:02:16.696 WARNING (MainThread) [homeassistant.util.loop] Detected blocking call to load_verify_locations with args (<ssl.SSLContext object at 0x7f191de3f110>, '/home/vscode/.local/ha-venv/lib/python3.13/site-packages/certifi/cacert.pem', None, None) inside the event loop by integration 'idrive_e2' at homeassistant/components/idrive_e2/__init__.py, line 46: await cast(Any, client).head_bucket(Bucket=entry.data[CONF_BUCKET]) (offender: /home/vscode/.local/ha-venv/lib/python3.13/site-packages/aiobotocore/httpsession.py, line 165: ssl_context.load_verify_locations(ca_certs, None, None)), please create a bug report at https://github.com/home-assistant/core/issues?q=is%3Aopen+is%3Aissue+label%3A%22integration%3A+idrive_e2%22
For developers, please see https://developers.home-assistant.io/docs/asyncio_blocking_operations/#load_verify_locations
Traceback (most recent call last):
  File "/home/vscode/.local/share/uv/python/cpython-3.13.11-linux-x86_64-gnu/lib/python3.13/runpy.py", line 198, in _run_module_as_main
    return _run_code(code, main_globals, None,
  File "/home/vscode/.local/share/uv/python/cpython-3.13.11-linux-x86_64-gnu/lib/python3.13/runpy.py", line 88, in _run_code
    exec(code, run_globals)
  File "/home/vscode/.vscode-server/extensions/ms-python.debugpy-2025.18.0-linux-x64/bundled/libs/debugpy/adapter/../../debugpy/launcher/../../debugpy/__main__.py", line 71, in <module>
    cli.main()
  File "/home/vscode/.vscode-server/extensions/ms-python.debugpy-2025.18.0-linux-x64/bundled/libs/debugpy/adapter/../../debugpy/launcher/../../debugpy/../debugpy/server/cli.py", line 508, in main
    run()
  File "/home/vscode/.vscode-server/extensions/ms-python.debugpy-2025.18.0-linux-x64/bundled/libs/debugpy/adapter/../../debugpy/launcher/../../debugpy/../debugpy/server/cli.py", line 391, in run_module
    run_module_as_main(options.target, alter_argv=True)
  File "/home/vscode/.vscode-server/extensions/ms-python.debugpy-2025.18.0-linux-x64/bundled/libs/debugpy/_vendored/pydevd/_pydevd_bundle/pydevd_runpy.py", line 228, in _run_module_as_main
    return _run_code(code, main_globals, None, "__main__", mod_spec)
  File "/home/vscode/.vscode-server/extensions/ms-python.debugpy-2025.18.0-linux-x64/bundled/libs/debugpy/_vendored/pydevd/_pydevd_bundle/pydevd_runpy.py", line 118, in _run_code
    exec(code, run_globals)
  File "/workspaces/core/homeassistant/__main__.py", line 229, in <module>
    sys.exit(main())
  File "/workspaces/core/homeassistant/__main__.py", line 215, in main
    exit_code = runner.run(runtime_conf)
  File "/workspaces/core/homeassistant/runner.py", line 289, in run
    return loop.run_until_complete(setup_and_run_hass(runtime_config))
  File "/home/vscode/.local/share/uv/python/cpython-3.13.11-linux-x86_64-gnu/lib/python3.13/asyncio/base_events.py", line 712, in run_until_complete
    self.run_forever()
  File "/home/vscode/.local/share/uv/python/cpython-3.13.11-linux-x86_64-gnu/lib/python3.13/asyncio/base_events.py", line 683, in run_forever
    self._run_once()
  File "/home/vscode/.local/share/uv/python/cpython-3.13.11-linux-x86_64-gnu/lib/python3.13/asyncio/base_events.py", line 2042, in _run_once
    handle._run()
  File "/home/vscode/.local/share/uv/python/cpython-3.13.11-linux-x86_64-gnu/lib/python3.13/asyncio/events.py", line 89, in _run
    self._context.run(self._callback, *self._args)
  File "/workspaces/core/homeassistant/config_entries.py", line 928, in async_setup_locked
    await self.async_setup(hass, integration=integration)
  File "/workspaces/core/homeassistant/config_entries.py", line 672, in async_setup
    await self.__async_setup_with_context(hass, integration)
  File "/workspaces/core/homeassistant/config_entries.py", line 762, in __async_setup_with_context
    result = await component.async_setup_entry(hass, self)
  File "/workspaces/core/homeassistant/components/idrive_e2/__init__.py", line 46, in async_setup_entry
    await cast(Any, client).head_bucket(Bucket=entry.data[CONF_BUCKET])

Checklist

  • I have reproduced in environment where pip check passes without errors
  • I have provided pip freeze results
  • I have provided sample code or detailed way to reproduce
  • I have tried the same code in botocore to ensure this is an aiobotocore specific issue
  • I have tried similar code in aiohttp to ensure this is is an aiobotocore specific issue
  • I have checked the latest and older versions of aiobotocore/aiohttp/python to see if this is a regression / injection

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions