mirror of
https://github.com/wassname/ray.git
synced 2026-07-04 22:29:46 +08:00
[Serve] Performance: Use uvloop when possible (#9216)
This commit is contained in:
@@ -7,9 +7,22 @@ from collections import namedtuple
|
||||
import time
|
||||
import inspect
|
||||
|
||||
try:
|
||||
import uvloop
|
||||
except ImportError:
|
||||
uvloop = None
|
||||
|
||||
import ray
|
||||
|
||||
|
||||
def get_new_event_loop():
|
||||
"""Construct a new event loop. Ray will use uvloop if it exists"""
|
||||
if uvloop:
|
||||
return uvloop.new_event_loop()
|
||||
else:
|
||||
return asyncio.new_event_loop()
|
||||
|
||||
|
||||
def sync_to_async(func):
|
||||
"""Convert a blocking function to async function"""
|
||||
|
||||
|
||||
Reference in New Issue
Block a user