mirror of
https://github.com/wassname/ray.git
synced 2026-07-12 05:29:00 +08:00
Make it possible to use actor definitions within remote functions and other actors. (#587)
* Enable remote function and actor definitions to close over actor definitions. * Give better error message if actor objects are pickled. * Add tests for closing over actor definitions. * Fix linting.
This commit is contained in:
committed by
Philipp Moritz
parent
bc8b0db13e
commit
c647dd5f6c
+4
-1
@@ -375,7 +375,7 @@ def make_actor(Class, num_cpus, num_gpus):
|
||||
# The following is needed so we can still access self.actor_methods.
|
||||
if attr in ["_manual_init", "_ray_actor_id", "_ray_actor_methods",
|
||||
"_actor_method_invokers", "_ray_method_signatures"]:
|
||||
return super(NewClass, self).__getattribute__(attr)
|
||||
return object.__getattribute__(self, attr)
|
||||
if attr in self._ray_actor_methods.keys():
|
||||
return self._actor_method_invokers[attr]
|
||||
# There is no method with this name, so raise an exception.
|
||||
@@ -385,6 +385,9 @@ def make_actor(Class, num_cpus, num_gpus):
|
||||
def __repr__(self):
|
||||
return "Actor(" + self._ray_actor_id.hex() + ")"
|
||||
|
||||
def __reduce__(self):
|
||||
raise Exception("Actor objects cannot be pickled.")
|
||||
|
||||
return NewClass
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user