mirror of
https://github.com/wassname/ray.git
synced 2026-09-10 12:38:43 +08:00
Implement select to enable waiting for a specific number of remote objects to be ready. (#369)
This commit is contained in:
@@ -897,6 +897,26 @@ static PyObject* request_object(PyObject* self, PyObject* args) {
|
||||
Py_RETURN_NONE;
|
||||
}
|
||||
|
||||
static PyObject* ray_select(PyObject* self, PyObject* args) {
|
||||
Worker* worker;
|
||||
PyObject* objectids;
|
||||
if (!PyArg_ParseTuple(args, "O&O", &PyObjectToWorker, &worker, &objectids)) {
|
||||
return NULL;
|
||||
}
|
||||
std::vector<ObjectID> objectids_vec;
|
||||
for (size_t i = 0; i < PyList_Size(objectids); ++i) {
|
||||
ObjectID objectid;
|
||||
PyObjectToObjectID(PyList_GetItem(objectids, i), &objectid);
|
||||
objectids_vec.push_back(objectid);
|
||||
}
|
||||
std::vector<int> indices = worker->select(objectids_vec);
|
||||
PyObject* result = PyList_New(indices.size());
|
||||
for (size_t i = 0; i < indices.size(); ++i) {
|
||||
PyList_SetItem(result, i, PyInt_FromLong(indices[i]));
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
static PyObject* alias_objectids(PyObject* self, PyObject* args) {
|
||||
Worker* worker;
|
||||
ObjectID alias_objectid;
|
||||
@@ -1061,6 +1081,7 @@ static PyMethodDef RayLibMethods[] = {
|
||||
{ "get_object", get_object, METH_VARARGS, "get protocol buffer object from the local object store" },
|
||||
{ "get_objectid", get_objectid, METH_VARARGS, "register a new object reference with the scheduler" },
|
||||
{ "request_object" , request_object, METH_VARARGS, "request an object to be delivered to the local object store" },
|
||||
{ "ray_select" , ray_select, METH_VARARGS, "checks the scheduler to see if a object can be gotten" },
|
||||
{ "alias_objectids", alias_objectids, METH_VARARGS, "make two objectids refer to the same object" },
|
||||
{ "wait_for_next_message", wait_for_next_message, METH_VARARGS, "get next message from scheduler (blocking)" },
|
||||
{ "submit_task", submit_task, METH_VARARGS, "call a remote function" },
|
||||
|
||||
Reference in New Issue
Block a user