Skip to content

Replace deprecated asyncio.get_event_loop() with asyncio.get_running_loop() in Snowflake search tool - #8911

Closed
LVsarff wants to merge 1 commit into
crewAIInc:mainfrom
LVsarff:fix/crewai-tools-get-running-loop
Closed

LVsarff wants to merge 1 commit into
crewAIInc:mainfrom
LVsarff:fix/crewai-tools-get-running-loop

Conversation

@LVsarff

@LVsarff LVsarff commented Nov 1, 2026 •

Copy link
Copy Markdown

Summary

asyncio.get_event_loop() is deprecated since Python 3.12 (and raises RuntimeError in Python 3.14 when no current loop exists). In coroutine contexts the recommended replacement is asyncio.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 an async def, so a loop is always running when await asyncio.get_running_loop().run_in_executor(...) is reached.

Note: the Snowflake tool's sibling stagehand_tool.py uses get_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_compile passes
  • ruff check --no-fix reports 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-generated label 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 via run_in_executor, but the loop is obtained with asyncio.get_running_loop() instead of the deprecated asyncio.get_event_loop().

Behavior is unchanged in this async def path (a loop is always running at that await). The swap avoids deprecation warnings on Python 3.12+ and RuntimeError on 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

@strix-security

strix-security Bot commented Nov 1, 2026 •

Copy link
Copy Markdown

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 summary

The PR is a one-line, behavior-identical async API swap: asyncio.get_event_loop() is replaced with asyncio.get_running_loop() in SnowflakeSearchTool._get_connection(). I confirmed the method is async def and its only call site is await self._get_connection() inside the async _execute_query(), so a loop is always running when the call is reached — the new call returns the same loop object the deprecated call did in that context, and the only observable difference is that an impossible no-running-loop invocation would fail closed with RuntimeError rather than silently binding a stale loop. No input handling, authentication, authorization, query construction, file access, or crypto logic is touched, and no security control is removed. No security issues found in the changed code.

Review 1 on this PR · 2b079d0 · requested Nov 1 13:00 UTC when the PR was opened


Reviewed by Strix
Re-run review · Configure security review settings

@github-actions

github-actions Bot commented Nov 1, 2026

Copy link
Copy Markdown
Contributor

Thanks for the pull request.

First-time contributors need an associated open issue before we can review a PR.

  1. Open an issue with a template, or pick an existing open one.
  2. Open a new PR (or reopen this one) whose title or body mentions that issue, for example #123.

See the contributing guide.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

needs-issue First-time contributor PR closed because it did not mention an open issue

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[BUG] Deprecated asyncio.get_event_loop() calls in lib/crewai and lib/crewai-tools

1 participant