[Serve] Performance: Use uvloop when possible (#9216)

This commit is contained in:
Simon Mo
2020-06-30 15:59:13 -07:00
committed by GitHub
parent 77933c922d
commit be647b69ab
8 changed files with 118 additions and 47 deletions
+13
View File
@@ -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"""