Repository navigation
Replace deprecated asyncio.get_event_loop() with asyncio.get_running_loop() in Snowflake search tool - #8911
Replace deprecated asyncio.get_event_loop() with asyncio.get_running_loop() in Snowflake search tool#8911LVsarff wants to merge 1 commit into
Conversation
…loop() in Snowflake search tool
Strix Security Review✅ No open security findings. PR summary: Replaces the deprecated `asyncio.get_event_loop()` with `asyncio.get_running_loop()` in the Snowflake search tool's async connection getter. A single-line compatibility fix for Python 3.12+ deprecation. Review summaryThe PR is a one-line, behavior-identical async API swap: Review 1 on this PR · Reviewed by Strix |
|
Thanks for the pull request. First-time contributors need an associated open issue before we can review a PR.
See the contributing guide. |
Summary
asyncio.get_event_loop()is deprecated since Python 3.12 (and raisesRuntimeErrorin Python 3.14 when no current loop exists). In coroutine contexts the recommended replacement isasyncio.get_running_loop(), which returns exactly the same loop with no deprecation.Changes
One-line, behavior-identical replacement in
lib/crewai-tools:src/crewai_tools/tools/snowflake_search_tool/snowflake_search_tool.py—_get_connection()is anasync def, so a loop is always running whenawait asyncio.get_running_loop().run_in_executor(...)is reached.Note: the Snowflake tool's sibling
stagehand_tool.pyusesget_event_loop()in sync bridge methods; that pattern requires a slightly larger refactor (handling the no-running-loop case), so it is intentionally left out of this minimal PR.Verification
py_compilepassesruff check --no-fixreports no new findings on the changed line (existing findings in this file are pre-existing and untouched)LLM disclosure
This change was prepared with the assistance of an AI coding agent and reviewed before submission. Per the repository's contribution guidelines, please add the
llm-generatedlabel to this PR if appropriate (I don't have permission to add labels myself).Note
Low Risk
Single-line asyncio API swap in an async-only code path; connection pooling and executor usage are unchanged.
Overview
Updates
SnowflakeSearchTool._get_connection()so that when the connection pool is empty, blocking Snowflake connect work still runs viarun_in_executor, but the loop is obtained withasyncio.get_running_loop()instead of the deprecatedasyncio.get_event_loop().Behavior is unchanged in this
async defpath (a loop is always running at thatawait). The swap avoids deprecation warnings on Python 3.12+ andRuntimeErroron Python 3.14 when no current loop exists.Reviewed by Cursor Bugbot for commit 2b079d0. Bugbot is set up for automated code reviews on this repo. Configure here.
Fixes #8912