Fix global state actors() call (#7567)

This commit is contained in:
Simon Mo
2020-03-11 16:59:50 -07:00
committed by GitHub
parent b38ed4be71
commit 31d63d3ca7
2 changed files with 32 additions and 2 deletions
+2 -2
View File
@@ -318,9 +318,9 @@ class GlobalState:
return {}
gcs_entries = gcs_utils.GcsEntry.FromString(message)
assert len(gcs_entries.entries) == 1
assert len(gcs_entries.entries) > 0
actor_table_data = gcs_utils.ActorTableData.FromString(
gcs_entries.entries[0])
gcs_entries.entries[-1])
actor_info = {
"ActorID": binary_to_hex(actor_table_data.actor_id),
+30
View File
@@ -76,6 +76,36 @@ def test_add_remove_cluster_resources(ray_start_cluster_head):
assert ray.cluster_resources()["CPU"] == 6
def test_global_state_actor_table(ray_start_regular):
@ray.remote
class Actor:
def ready(self):
pass
# actor table should be empty at first
assert len(ray.actors()) == 0
# actor table should contain only one entry
a = Actor.remote()
ray.get(a.ready.remote())
assert len(ray.actors()) == 1
# actor table should contain only this entry
# even when the actor goes out of scope
del a
def get_state():
return list(ray.actors().values())[0]["State"]
dead_state = ray.gcs_utils.ActorTableData.DEAD
for _ in range(10):
if get_state() == dead_state:
break
else:
time.sleep(0.5)
assert get_state() == dead_state
if __name__ == "__main__":
import pytest
import sys