mirror of
https://github.com/wassname/ray.git
synced 2026-07-19 11:27:32 +08:00
Implement async get for direct actor call (#6339)
This commit is contained in:
@@ -192,6 +192,7 @@ cdef extern from "ray/common/ray_object.h" nogil:
|
||||
const size_t DataSize() const
|
||||
const shared_ptr[CBuffer] &GetData()
|
||||
const shared_ptr[CBuffer] &GetMetadata() const
|
||||
c_bool IsInPlasmaError() const
|
||||
|
||||
cdef extern from "ray/core_worker/common.h" nogil:
|
||||
cdef cppclass CRayFunction "ray::RayFunction":
|
||||
|
||||
@@ -36,6 +36,10 @@ from ray.includes.libraylet cimport CRayletClient
|
||||
ctypedef unordered_map[c_string, c_vector[pair[int64_t, double]]] \
|
||||
ResourceMappingType
|
||||
|
||||
ctypedef void (*ray_callback_function) \
|
||||
(shared_ptr[CRayObject] result_object,
|
||||
CObjectID object_id, void* user_data)
|
||||
|
||||
cdef extern from "ray/core_worker/profiling.h" nogil:
|
||||
cdef cppclass CProfiler "ray::worker::Profiler":
|
||||
void Start()
|
||||
@@ -145,3 +149,7 @@ cdef extern from "ray/core_worker/core_worker.h" nogil:
|
||||
|
||||
CWorkerContext &GetWorkerContext()
|
||||
void YieldCurrentFiber(CFiberEvent &coroutine_done)
|
||||
void GetAsync(const CObjectID &object_id,
|
||||
ray_callback_function successs_callback,
|
||||
ray_callback_function fallback_callback,
|
||||
void* python_future)
|
||||
|
||||
@@ -196,6 +196,15 @@ cdef class ObjectID(BaseID):
|
||||
def from_random(cls):
|
||||
return cls(CObjectID.FromRandom().Binary())
|
||||
|
||||
def __await__(self):
|
||||
# Delayed import because this can only be imported in py3.
|
||||
from ray.async_compat import get_async
|
||||
return get_async(self).__await__()
|
||||
|
||||
def as_future(self):
|
||||
# Delayed import because this can only be imported in py3.
|
||||
from ray.async_compat import get_async
|
||||
return get_async(self)
|
||||
|
||||
cdef class TaskID(BaseID):
|
||||
cdef CTaskID data
|
||||
|
||||
Reference in New Issue
Block a user