Skip to content

Commit 217031a

Browse files
authored
Define an env for controlling UVloop (#58442)
> Briefly describe what this PR accomplishes and why it's needed. Our serve ingress keeps running into below error related to `uvloop` under heavy load ``` File descriptor 97 is used by transport ``` The uvloop team have a [PR](MagicStack/uvloop#646) to fix it, but seems like no one is working on it One of workaround mentioned in the ([PR](MagicStack/uvloop#646 (comment))) is to just turn off uvloop . We tried it in our env and didn't see any major performance difference Hence as part of this PR, we are defining a new env for controlling UVloop Signed-off-by: jugalshah291 <[email protected]>
1 parent 2486ddd commit 217031a

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

python/ray/_private/async_compat.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,23 +6,25 @@
66
import inspect
77
from functools import lru_cache
88

9+
from ray._private.ray_constants import env_bool
10+
911
try:
1012
import uvloop
1113
except ImportError:
1214
uvloop = None
1315

1416

1517
def get_new_event_loop():
16-
"""Construct a new event loop. Ray will use uvloop if it exists"""
17-
if uvloop:
18+
"""Construct a new event loop. Ray will use uvloop if it exists and is enabled"""
19+
if uvloop and env_bool("RAY_USE_UVLOOP", True):
1820
return uvloop.new_event_loop()
1921
else:
2022
return asyncio.new_event_loop()
2123

2224

2325
def try_install_uvloop():
24-
"""Installs uvloop as event-loop implementation for asyncio (if available)"""
25-
if uvloop:
26+
"""Installs uvloop as event-loop implementation for asyncio (if available and enabled)"""
27+
if uvloop and env_bool("RAY_USE_UVLOOP", True):
2628
uvloop.install()
2729
else:
2830
pass

0 commit comments

Comments
 (0)