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:
Robert Nishihara
2017-05-24 15:43:32 -07:00
committed by Philipp Moritz
parent bc8b0db13e
commit c647dd5f6c
2 changed files with 49 additions and 47 deletions
+4 -1
View File
@@ -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