Fix unawaited coroutine warning and treat as test error#2806
Conversation
- Add pytest filterwarnings to fail tests on unawaited coroutine warnings - Fix _await_with_session_monitoring to close coroutine before raising when session task is already done
WalkthroughThis PR modifies the Possibly related PRs
🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing touches
📜 Recent review detailsConfiguration used: Organization UI Review profile: CHILL Plan: Pro ⛔ Files ignored due to path filters (1)
📒 Files selected for processing (1)
🧰 Additional context used📓 Path-based instructions (1)src/fastmcp/**/*.py📄 CodeRabbit inference engine (AGENTS.md)
Files:
⏰ 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). (5)
🔇 Additional comments (1)
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 |
When
_await_with_session_monitoringdetects that the session task is already done, it raises immediately without closing the passed coroutine. This causes "coroutine was never awaited" warnings during test teardown.Fix: Call
coro.close()before raising to properly clean up the coroutine.Prevention: Add pytest filterwarnings to treat unawaited coroutine warnings as errors so future occurrences will fail tests rather than emit warnings.