mirror of
https://github.com/wassname/ray.git
synced 2026-07-04 07:18:12 +08:00
Allow manually writing to return ObjectIDs from tasks/actor methods (#3805)
This commit is contained in:
committed by
Robert Nishihara
parent
7c3274e65b
commit
c93eb126ec
+14
-2
@@ -25,6 +25,7 @@ import pyarrow
|
||||
import pyarrow.plasma as plasma
|
||||
import ray.cloudpickle as pickle
|
||||
import ray.experimental.signal as ray_signal
|
||||
import ray.experimental.no_return
|
||||
import ray.experimental.state as state
|
||||
import ray.gcs_utils
|
||||
import ray.memory_monitor as memory_monitor
|
||||
@@ -164,6 +165,7 @@ class Worker(object):
|
||||
# Index of the current session. This number will
|
||||
# increment every time when `ray.shutdown` is called.
|
||||
self._session_index = 0
|
||||
self._current_task = None
|
||||
|
||||
@property
|
||||
def task_context(self):
|
||||
@@ -790,8 +792,15 @@ class Worker(object):
|
||||
if isinstance(outputs[i], ray.actor.ActorHandle):
|
||||
raise Exception("Returning an actor handle from a remote "
|
||||
"function is not allowed).")
|
||||
|
||||
self.put_object(object_ids[i], outputs[i])
|
||||
if outputs[i] is ray.experimental.no_return.NoReturn:
|
||||
if not self.plasma_client.contains(
|
||||
pyarrow.plasma.ObjectID(object_ids[i].binary())):
|
||||
raise RuntimeError(
|
||||
"Attempting to return 'ray.experimental.NoReturn' "
|
||||
"from a remote function, but the corresponding "
|
||||
"ObjectID does not exist in the local object store.")
|
||||
else:
|
||||
self.put_object(object_ids[i], outputs[i])
|
||||
|
||||
def _process_task(self, task, function_execution_info):
|
||||
"""Execute a task assigned to this worker.
|
||||
@@ -847,6 +856,7 @@ class Worker(object):
|
||||
|
||||
# Execute the task.
|
||||
try:
|
||||
self._current_task = task
|
||||
with profiling.profile("task:execute"):
|
||||
if (task.actor_id().is_nil()
|
||||
and task.actor_creation_id().is_nil()):
|
||||
@@ -867,6 +877,8 @@ class Worker(object):
|
||||
self._handle_process_task_failure(
|
||||
function_descriptor, return_object_ids, e, traceback_str)
|
||||
return
|
||||
finally:
|
||||
self._current_task = None
|
||||
|
||||
# Store the outputs in the local object store.
|
||||
try:
|
||||
|
||||
Reference in New Issue
Block a user