Implement async get for direct actor call (#6339)

This commit is contained in:
Simon Mo
2019-12-18 11:50:21 -08:00
committed by GitHub
parent ec4f8d5311
commit 26ec500ef9
13 changed files with 263 additions and 8 deletions
+17
View File
@@ -61,6 +61,8 @@ LOCAL_MODE = 2
ERROR_KEY_PREFIX = b"Error:"
PY3 = sys.version_info.major >= 3
# Logger for this module. It should be configured at the entry point
# into the program using Ray. Ray provides a default configuration at
# entry/init points.
@@ -1436,6 +1438,14 @@ def get(object_ids, timeout=None):
"""
worker = global_worker
worker.check_connected()
if PY3 and hasattr(
worker,
"core_worker") and worker.core_worker.current_actor_is_asyncio():
raise RayError("Using blocking ray.get inside async actor. "
"This blocks the event loop. Please "
"use `await` on object id with asyncio.gather.")
with profiling.profile("ray.get"):
is_individual_id = isinstance(object_ids, ray.ObjectID)
if is_individual_id:
@@ -1548,6 +1558,13 @@ def wait(object_ids, num_returns=1, timeout=None):
"""
worker = global_worker
if PY3 and hasattr(
worker,
"core_worker") and worker.core_worker.current_actor_is_asyncio():
raise RayError("Using blocking ray.wait inside async method. "
"This blocks the event loop. Please use `await` "
"on object id with asyncio.wait. ")
if isinstance(object_ids, ObjectID):
raise TypeError(
"wait() expected a list of ray.ObjectID, got a single ray.ObjectID"