python runtime_error ai_generated true

ExceptionGroup: TaskGroup 中未处理的错误

ExceptionGroup: unhandled errors in a TaskGroup

ID: python/asyncio-task-group-exception

其他格式: JSON · Markdown 中文 · English
80%修复率
84%置信度
0证据数
2024-07-22首次发现

版本兼容性

版本状态引入弃用备注
3.11 active

根因分析

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

English

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

generic

解决方案

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

无效尝试

常见但无效的做法:

  1. 80% 失败

  2. 50% 失败