Consolidate session state reset logic and improve cancellation cleanup#2615
Consolidate session state reset logic and improve cancellation cleanup#2615
Conversation
WalkthroughThe pull request refactors session state management in the FastMCP client by introducing a private Pre-merge checks and finishing touches❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✨ Finishing touches
🧪 Generate unit tests (beta)
📜 Recent review detailsConfiguration used: CodeRabbit UI Review profile: CHILL Plan: Pro 📒 Files selected for processing (1)
🧰 Additional context used📓 Path-based instructions (1)**/*.py📄 CodeRabbit inference engine (AGENTS.md)
Files:
🧠 Learnings (1)📓 Common learnings🪛 Ruff (0.14.8)src/fastmcp/client/client.py542-542: Do not catch blind exception: (BLE001) 554-554: Do not catch blind exception: (BLE001) ⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (4)
🔇 Additional comments (3)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Follow-up to #2614 that consolidates the session state reset logic and adds robustness improvements to the cancellation cleanup path.
Changes:
_reset_session_state()helper to consolidate duplicated state reset logic between_context_managerand the cancellation cleanupanyio.CancelScope(shield=True)to protect cleanup from outer cancellationsession_taskmust remain an asyncio.Task (anyio's structured concurrency doesn't allow tasks to escape their task group)