fix: use running loop in async paths#5901
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (3)
📝 WalkthroughWalkthroughThis PR updates three async execution paths to use ChangesAsync Event Loop Context Refactor
Estimated code review effort🎯 1 (Trivial) | ⏱️ ~3 minutes Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
Summary
asyncio.get_event_loop()withasyncio.get_running_loop()in async execution pathsProblem
asyncio.get_event_loop()is legacy behavior in modern Python and can warn or behave differently when no loop is set on the current thread. These call sites are already inside async execution paths, so the running event loop is the loop they need.Before / After
Before, async code asked asyncio for the current event loop policy result with
get_event_loop().After, the code explicitly uses the active running loop with
get_running_loop(), matching the async context these functions run in.Verification
python -m compileall -q lib\crewai\src\crewai\tools\structured_tool.py lib\crewai\src\crewai\utilities\streaming.py lib\crewai\src\crewai\rag\chromadb\client.pygit diff --checkSummary by CodeRabbit