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

Detected blocking call inside the event loop #3222

Closed
chemelli74 opened this issue Jul 17, 2024 · 1 comment
Closed

Detected blocking call inside the event loop #3222

chemelli74 opened this issue Jul 17, 2024 · 1 comment
Assignees
Labels

Comments

@chemelli74
Copy link

Describe the bug

Home Assistant since a few version detects blocking calls.

One is related to botocore and surfaces via aiobotocore.
I opened a PR to fix it, but I was redirected here ( aio-libs/aiobotocore#1120 )

Expected Behavior

Avoid blocking calls inside the event loop

Current Behavior

There are blocking calls inside the event loop

Reproduction Steps

  1. Install Home Assistant >= 2024.6.0
  2. Configure AWS integration
  3. Check log

Possible Solution

None

Additional Information/Context

2024-07-17 18:41:54.986 WARNING (MainThread) [homeassistant.util.loop] Detected blocking call to listdir with args ('/usr/local/lib/python3.12/site-packages/botocore/data/sns',) inside the event loop by integration 'aws' at homeassistant/components/aws/notify.py, line 38: return await session.get_available_regions(service) (offender: /usr/local/lib/python3.12/site-packages/botocore/loaders.py, line 363: for dirname in os.listdir(possible_path):), please create a bug report at https://github.com/home-assistant/core/issues?q=is%3Aopen+is%3Aissue+label%3A%22integration%3A+aws%22
For developers, please see https://developers.home-assistant.io/docs/asyncio_blocking_operations/#listdir
Traceback (most recent call last):
2024-07-17 18:41:54.994 WARNING (MainThread) [homeassistant.util.loop] Detected blocking call to open with args ('/usr/local/lib/python3.12/site-packages/botocore/data/sns/2010-03-31/service-2.json.gz', 'rb') inside the event loop by integration 'aws' at homeassistant/components/aws/notify.py, line 38: return await session.get_available_regions(service) (offender: /usr/local/lib/python3.12/gzip.py, line 192: fileobj = self.myfileobj = builtins.open(filename, mode or 'rb')), please create a bug report at https://github.com/home-assistant/core/issues?q=is%3Aopen+is%3Aissue+label%3A%22integration%3A+aws%22
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 190, in run

SDK version used

1.34.131

Environment details (OS name and version, etc.)

Home Assistant Core (docker container): Alpine Linux v3.20.1

@chemelli74 chemelli74 added bug This issue is a confirmed bug. needs-triage This issue or PR still needs to be triaged. labels Jul 17, 2024
@tim-finnigan tim-finnigan self-assigned this Jul 23, 2024
@tim-finnigan tim-finnigan added the investigating This issue is being investigated and/or work is in progress to resolve the issue. label Jul 23, 2024
@tim-finnigan
Copy link
Contributor

Thanks for reaching out. Boto3/Botocore does not use an event loop, that is all on the aiobotocore side. (Documentation on the Boto3 event system can be found here).

Regarding the discussion in aio-libs/aiobotocore#1120 around the service models, the team has already made optimizations to reduce the size of the models. There are also open issues like #2365 and boto/boto3#3197 tracking the request to implement further improvements. On the topic of multithreading you can refer to the documentation for sessions (not thread safe) and clients.

We cannot guarantee compatibility with third-party software like Home Assistant or aiobotocore. For requests that directly involve Boto3/Botocore you can +1 (👍) existing issues or share a code snippet and logs to highlight the problem you're experiencing.

@tim-finnigan tim-finnigan added feature-request This issue requests a feature. closing-soon third-party and removed bug This issue is a confirmed bug. investigating This issue is being investigated and/or work is in progress to resolve the issue. needs-triage This issue or PR still needs to be triaged. labels Jul 23, 2024
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

2 participants