A `ThreadPoolExecutor` job finishes "successfully" but half the work is missing, with no errors logged.
IntermediateTroubleshootingConcurrency, async, tests, services & containers
Answer
Likely causes → Exceptions inside worker functions are stored in the futures and only raised when .result() is called; the code submitted tasks and never checked results.
Diagnose → Iterate futures and call f.exception().
Fix →
for f in as_completed(futures):
try:
f.result()
except Exception:
log.exception("task %s failed", futures[f])
failures += 1
sys.exit(1 if failures else 0)
Prevent → Always consume results; fail the run when any task fails.
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.Advanced`OSError: [Errno 24] Too many open files` from an asyncio scanner with 20,000 targets.IntermediateIntermittent `KeyError: 'credential_provider'` or `KeyError: 'endpoint_resolver'` when creating boto3 clients from many threads.Advanced