Commit dfb3295
fix: shield cleanup operations from cancel scope conflicts
Apply CancelScope(shield=True) to prevent RuntimeError when cleaning up
HTTP MCP clients. This fixes the 'Attempted to exit cancel scope in a
different task' error that occurs with asyncio.
Changes:
- session.py: Shield cleanup in _receive_loop finally block
- streamable_http.py: Shield terminate_session and stream cleanup
Based on v1.26.0 to maintain compatibility with openai-agents SDK.
Related to: modelcontextprotocol#577
Based on: modelcontextprotocol#18171 parent 3d9d345 commit dfb3295
2 files changed
Lines changed: 19 additions & 13 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
673 | 673 | | |
674 | 674 | | |
675 | 675 | | |
676 | | - | |
677 | | - | |
| 676 | + | |
| 677 | + | |
| 678 | + | |
| 679 | + | |
678 | 680 | | |
679 | 681 | | |
680 | | - | |
681 | | - | |
| 682 | + | |
| 683 | + | |
| 684 | + | |
| 685 | + | |
682 | 686 | | |
683 | 687 | | |
684 | 688 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
445 | 445 | | |
446 | 446 | | |
447 | 447 | | |
448 | | - | |
449 | | - | |
450 | | - | |
451 | | - | |
452 | | - | |
453 | | - | |
454 | | - | |
455 | | - | |
456 | | - | |
| 448 | + | |
| 449 | + | |
| 450 | + | |
| 451 | + | |
| 452 | + | |
| 453 | + | |
| 454 | + | |
| 455 | + | |
| 456 | + | |
| 457 | + | |
| 458 | + | |
457 | 459 | | |
458 | 460 | | |
459 | 461 | | |
| |||
0 commit comments