Repository navigation
Replace deprecated asyncio.get_event_loop() with asyncio.get_running_loop() in Snowflake search tool - #8915
Replace deprecated asyncio.get_event_loop() with asyncio.get_running_loop() in Snowflake search tool#8915LVsarff wants to merge 1 commit into
Conversation
…loop() in Snowflake search tool
Strix Security Review✅ No open security findings. PR summary: Replaces `asyncio.get_event_loop()` with `asyncio.get_running_loop()` in the Snowflake search tool's async connection helper to avoid the Python 3.12+ deprecation, with no behavior change since a loop is always running in that coroutine. Review summaryThe PR makes a single-line, semantics-preserving change in the Snowflake search tool, replacing the deprecated Review 1 on this PR · Reviewed by Strix |
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)Fixes #8912
Note: this PR supersedes #8911, which was submitted without an issue reference and auto-closed by the first-time-contributor gate as a result (reopen is not permitted for external contributors).
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 method with no logic or connection-handling changes.
Overview
Updates
SnowflakeSearchTool._get_connection()so that when the connection pool is empty, blocking Snowflake connection creation still runs viarun_in_executor, but the event loop is obtained withasyncio.get_running_loop()instead of the deprecatedasyncio.get_event_loop().This is a behavior-preserving change for Python 3.12+ (and avoids
RuntimeErrorwhen no loop is set in 3.14), because_get_connectionis only called from async code paths where a loop is already running.Reviewed by Cursor Bugbot for commit 2b079d0. Bugbot is set up for automated code reviews on this repo. Configure here.