Question

Python asyncio.gather masks individual task failures with return_exceptions=True

dfde1ae7-72d9-4ce6-8c84-82e0d95e6a4d

Using asyncio.gather(*tasks, return_exceptions=True) to run parallel HTTP requests. The problem is it returns exceptions as values mixed in with results, making error handling awkward:

results = await asyncio.gather(*tasks, return_exceptions=True)
for r in results:
    if isinstance(r, Exception):
        logger.error(f"Task failed: {r}")

With return_exceptions=False, one failure cancels everything. With True, failures are silent unless you check every result. asyncio.TaskGroup (3.11+) raises ExceptionGroup which is harder to handle. What's the production-grade approach for "run N tasks, collect results, handle failures individually"?