`OSError: [Errno 24] Too many open files` from an asyncio scanner with 20,000 targets.
IntermediateTroubleshootingConcurrency, async, tests, services & containers
Answer
Likely causes → All coroutines start at once and each opens a socket; no concurrency bound.
Diagnose → ulimit -n; count concurrent connections (ss -s).
Fix → Wrap each request in async with asyncio.Semaphore(200), and configure client connection limits (httpx.Limits(max_connections=200), aiohttp TCPConnector(limit=200)).
Prevent → Always bound concurrency explicitly; never gather an unbounded list of network calls.
More on Concurrency, async, tests, services & containers
`RuntimeError: asyncio.run() cannot be called from a running event loop` in a Jupyter notebook or inside an async framework.Intermediate`RuntimeWarning: coroutine 'fetch' was never awaited` and nothing happens.BeginnerAn asyncio health-checker is no faster than a sequential loop.Advanced`Task was destroyed but it is pending!` at shutdown.AdvancedA `ThreadPoolExecutor` job finishes "successfully" but half the work is missing, with no errors logged.IntermediateIntermittent `KeyError: 'credential_provider'` or `KeyError: 'endpoint_resolver'` when creating boto3 clients from many threads.Advanced