From 1d44980be269f0ac86e21bdf2ffea9f9660f8e02 Mon Sep 17 00:00:00 2001 From: Ishaan Jaffer Date: Wed, 6 May 2026 15:37:35 -0700 Subject: [PATCH] fix(internal_endpoints): use asyncio.get_running_loop() not get_event_loop asyncio.get_event_loop() is deprecated inside a running coroutine (Python 3.10+). Replace the two call sites in daemon_get_next_queued_run with asyncio.get_running_loop(). Greptile P2. --- litellm/proxy/agent_session_endpoints/internal_endpoints.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/litellm/proxy/agent_session_endpoints/internal_endpoints.py b/litellm/proxy/agent_session_endpoints/internal_endpoints.py index 65326180a3b..677ab88e801 100644 --- a/litellm/proxy/agent_session_endpoints/internal_endpoints.py +++ b/litellm/proxy/agent_session_endpoints/internal_endpoints.py @@ -179,7 +179,9 @@ async def daemon_next_run( the same row. """ prisma_client = await _get_prisma_client_or_503() - deadline = asyncio.get_event_loop().time() + NEXT_RUN_LONG_POLL_TIMEOUT_SECONDS + # ``get_running_loop`` (not ``get_event_loop``) is the correct API + # inside a running coroutine — see Python 3.10 deprecation. + deadline = asyncio.get_running_loop().time() + NEXT_RUN_LONG_POLL_TIMEOUT_SECONDS while True: claimed = await _claim_next_queued_run(prisma_client, session_id) @@ -188,7 +190,7 @@ async def daemon_next_run( run_id=claimed.id, prompt=claimed.prompt or {}, ) - if asyncio.get_event_loop().time() >= deadline: + if asyncio.get_running_loop().time() >= deadline: return Response(status_code=204) await asyncio.sleep(NEXT_RUN_POLL_INTERVAL_SECONDS)