python runtime_error ai_generated true

ExceptionGroup: unhandled errors in a TaskGroup

ID: python/asyncio-task-group-exception

Also available as: JSON · Markdown · 中文
80%Fix Rate
84%Confidence
0Evidence
2024-07-22First Seen

Version Compatibility

VersionStatusIntroducedDeprecatedNotes
3.11 active

Root Cause

Multiple exceptions raised in asyncio.TaskGroup are aggregated into ExceptionGroup, requiring special handling.

generic

中文

asyncio.TaskGroup 中多个异常被聚合为 ExceptionGroup,需要特殊处理。

Workarounds

  1. 90% success
    except* Exception: # handle all exceptions in group
  2. 85% success
    for ex in eg.exceptions: # iterate and handle individually

Dead Ends

Common approaches that don't work:

  1. 80% fail

  2. 50% fail