asyncio.gather silently swallowing exceptions since 3.11
I've got a worker that fires off about twenty coroutines with asyncio.gather(..., return_exceptions=True). Since moving to Python 3.11 I'm getting weird results — one task raises a TimeoutError and instead of seeing it in my logs I just get the exception object mixed into my results list. My try/except around the gather never fires. What's the idiomatic way to log which coroutine failed without losing the successful results? I can't just drop return_exceptions because one bad task kills the whole batch. Slightly losing my mind here.
4 replies