From 854976b213147176292acbc74047e3bead477141 Mon Sep 17 00:00:00 2001 From: jugalshah291 Date: Thu, 6 Nov 2025 17:26:12 -0800 Subject: [PATCH] Put UVloop behind a env Signed-off-by: jugalshah291 --- python/ray/_private/async_compat.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/python/ray/_private/async_compat.py b/python/ray/_private/async_compat.py index a9081c2719b3..64644346893f 100644 --- a/python/ray/_private/async_compat.py +++ b/python/ray/_private/async_compat.py @@ -6,6 +6,8 @@ import inspect from functools import lru_cache +from ray._private.ray_constants import env_bool + try: import uvloop except ImportError: @@ -13,16 +15,16 @@ def get_new_event_loop(): - """Construct a new event loop. Ray will use uvloop if it exists""" - if uvloop: + """Construct a new event loop. Ray will use uvloop if it exists and is enabled""" + if uvloop and env_bool("RAY_USE_UVLOOP", True): return uvloop.new_event_loop() else: return asyncio.new_event_loop() def try_install_uvloop(): - """Installs uvloop as event-loop implementation for asyncio (if available)""" - if uvloop: + """Installs uvloop as event-loop implementation for asyncio (if available and enabled)""" + if uvloop and env_bool("RAY_USE_UVLOOP", True): uvloop.install() else: pass