mirror of
https://github.com/wassname/ray.git
synced 2026-07-20 12:40:20 +08:00
Implement async get for direct actor call (#6339)
This commit is contained in:
@@ -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"
|
||||
|
||||
Reference in New Issue
Block a user