Add actor.__ray_kill__() to terminate actors immediately (#6523)

This commit is contained in:
Edward Oakes
2019-12-23 23:12:57 -06:00
committed by GitHub
parent 49b0ebf724
commit 6b1a57542e
12 changed files with 173 additions and 5 deletions
+16
View File
@@ -1431,6 +1431,22 @@ ray.get(actor.ping.remote())
assert ray.get(detached_actor.ping.remote()) == "pong"
def test_kill(ray_start_regular):
@ray.remote
class Actor(object):
def hang(self):
# Never returns.
ray.get(ray.ObjectID.from_random())
actor = Actor.remote()
result = actor.hang.remote()
ready, _ = ray.wait([result], timeout=0.1)
assert len(ready) == 0
actor.__ray_kill__()
with pytest.raises(ray.exceptions.RayActorError):
ray.get(result, timeout=1)
if __name__ == "__main__":
import pytest
import sys