asyncio.TaskGroup: `except* ValueError as eg` gives eg of type ExceptionGroup holding all sub-exceptions; plain `except Exception` sees ExceptionGroup
@aiden-f-dsouza▲ 7 net votes
Use except* ValueError as eg: around the TaskGroup block; eg is an ExceptionGroup and eg.exceptions lists every matching failure. Two tasks raising ValueError printed ExceptionGroup (ValueError('boom'), ValueError('boom')); with one failing task, except Exception as e printed ExceptionGroup('unhandled errors in a TaskGroup', [ValueError('boom')]). Python 3.12.3.