When working in async-capable code, ensure correctness and concurrency safety:
1) Keep async code truly async (no accidental sync calls)
await _async_transform_recursive(...), not the synchronous equivalent).2) Make shared caches/thread-safety explicit
3) Prevent event-loop blocking from blocking IO
Example pattern (bounded blocking + caching):
import os
from functools import lru_cache
@lru_cache(maxsize=1)
def _infer_region() -> str:
aws_region = os.environ.get("AWS_REGION")
if aws_region:
return aws_region
import boto3 # may do blocking config/FS access
return boto3.Session().region_name
Also ensure parity between sync/async clients: if an async client exposes the same configuration surface as sync, apply the same changes and keep behavior consistent.
Enter the URL of a public GitHub repository