Open
Description
Describe the bug
Home Assitant recently added the ability to detect I/O function that block event loop:
2024-06-12 09:40:41.237 WARNING (MainThread) [homeassistant.util.loop] Detected blocking call to listdir 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-pa
ckages/botocore/loaders.py, line 311: api_versions = os.listdir(full_dirname)), please create a bug report at https://github.com/home-assistant/core
/issues?q=is%3Aopen+is%3Aissue+label%3A%22integration%3A+aws%22
After trying a first fix in #1120, I was redirected to botocore.
I opened a issue there: boto/botocore#3222, but was closed as botocore doesn't use event loop at all.
After some more discussions in the original PR, a new idea was raised and I applied it to a new fix in #1196.
Lately I was asked to open a issue to discuss the approach.
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
pip freeze results
pip_freeze.txt
Environment:
- Python Version: 3.12.4
- OS name and version: alpine-release 3.20.1
Additional context
Add any other context about the problem here.