File tree Expand file tree Collapse file tree 1 file changed +10
-1
lines changed Expand file tree Collapse file tree 1 file changed +10
-1
lines changed Original file line number Diff line number Diff line change @@ -270,7 +270,16 @@ async def _cleanup_tasks(self):
270270
271271 # Wait for all cancelled tasks to complete and collect exceptions
272272 if tasks :
273- await asyncio .gather (* tasks , return_exceptions = True )
273+ results = await asyncio .gather (* tasks , return_exceptions = True )
274+ # Check if any task failed with a real exception (not CancelledError)
275+ # This catches exceptions that occurred after _check_errors() but before cancellation
276+ if not self ._stored_exception :
277+ for result in results :
278+ is_exception = isinstance (result , Exception )
279+ is_not_cancelled = not isinstance (result , asyncio .CancelledError )
280+ if is_exception and is_not_cancelled :
281+ self ._stored_exception = result
282+ break
274283
275284 def _check_errors (self ):
276285 """Check for exceptions in completed tasks.
You can’t perform that action at this time.
0 commit comments