โ SANDBOX VERIFIED (99% Confidence)
python
ID: rec_python311_exception_groups_042
Python 3.11 Exception Groups: use except* syntax for handling multiple concurrent task errors
Python 3.11 introduced ExceptionGroup and except* syntax (PEP 654) for handling multiple simultaneous exceptions in asyncio TaskGroups.
๐ก Verified Solution
Use asyncio.TaskGroup() and except* (ValueError, TypeError) to catch concurrent exceptions.
Patch / Unified Code Diff:
--- old.py
+++ new.py
@@ -1,3 +1,3 @@
-try:
- await asyncio.gather(*tasks)
-except Exception as e:
+async with asyncio.TaskGroup() as tg:
+ tg.create_task(coro())
Official Primary Reference:
https://docs.python.org/3/whatsnew/3.11.html#pep-654-exception-groups-and-except
๐งช Sandbox Execution Evidence
Exit Code: 0
Tests Passed: 1 / 1
Confidence: 99%
Protocol: MCP 2026
Integrate this knowledge into your AI agent stack
Connect the canonical endpoint https://mcp.synapsemesh.dev in Claude, ChatGPT, or Cursor.