fix: avoid event loop deadlock in snowflake pool lock

This commit is contained in:
Greyson Lalonde
2026-03-12 22:21:18 -04:00
parent 0228445080
commit a41cfbd9f6

View File

@@ -166,12 +166,11 @@ class SnowflakeSearchTool(BaseTool):
if self._connection_pool is None: if self._connection_pool is None:
raise RuntimeError("Connection pool not initialized") raise RuntimeError("Connection pool not initialized")
with self._pool_lock: with self._pool_lock:
if not self._connection_pool: if self._connection_pool:
conn = await asyncio.get_event_loop().run_in_executor( return self._connection_pool.pop()
self._thread_pool, self._create_connection return await asyncio.get_event_loop().run_in_executor(
) self._thread_pool, self._create_connection
self._connection_pool.append(conn) )
return self._connection_pool.pop()
def _create_connection(self) -> SnowflakeConnection: def _create_connection(self) -> SnowflakeConnection:
"""Create a new Snowflake connection.""" """Create a new Snowflake connection."""