mirror of
https://github.com/wassname/ray.git
synced 2026-06-29 06:33:06 +08:00
Fix global state actors() call (#7567)
This commit is contained in:
+2
-2
@@ -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),
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user