mirror of
https://github.com/wassname/ray.git
synced 2026-07-19 11:27:32 +08:00
Move global state API out of global_state object. (#4857)
This commit is contained in:
committed by
Philipp Moritz
parent
ea8d7b4dc0
commit
6703519144
@@ -30,17 +30,16 @@ def _test_cleanup_on_driver_exit(num_redis_shards):
|
||||
time.sleep(2)
|
||||
|
||||
def StateSummary():
|
||||
obj_tbl_len = len(ray.global_state.object_table())
|
||||
task_tbl_len = len(ray.global_state.task_table())
|
||||
func_tbl_len = len(ray.global_state.function_table())
|
||||
return obj_tbl_len, task_tbl_len, func_tbl_len
|
||||
obj_tbl_len = len(ray.objects())
|
||||
task_tbl_len = len(ray.tasks())
|
||||
return obj_tbl_len, task_tbl_len
|
||||
|
||||
def Driver(success):
|
||||
success.value = True
|
||||
# Start driver.
|
||||
ray.init(redis_address=redis_address)
|
||||
summary_start = StateSummary()
|
||||
if (0, 1) != summary_start[:2]:
|
||||
if (0, 1) != summary_start:
|
||||
success.value = False
|
||||
|
||||
# Two new objects.
|
||||
@@ -54,7 +53,7 @@ def _test_cleanup_on_driver_exit(num_redis_shards):
|
||||
|
||||
# 1 new function.
|
||||
attempts = 0
|
||||
while (2, 1, summary_start[2]) != StateSummary():
|
||||
while (2, 1) != StateSummary():
|
||||
time.sleep(0.1)
|
||||
attempts += 1
|
||||
if attempts == max_attempts_before_failing:
|
||||
@@ -63,7 +62,7 @@ def _test_cleanup_on_driver_exit(num_redis_shards):
|
||||
|
||||
ray.get(f.remote())
|
||||
attempts = 0
|
||||
while (4, 2, summary_start[2] + 1) != StateSummary():
|
||||
while (4, 2) != StateSummary():
|
||||
time.sleep(0.1)
|
||||
attempts += 1
|
||||
if attempts == max_attempts_before_failing:
|
||||
@@ -83,12 +82,12 @@ def _test_cleanup_on_driver_exit(num_redis_shards):
|
||||
# Check that objects, tasks, and functions are cleaned up.
|
||||
ray.init(redis_address=redis_address)
|
||||
attempts = 0
|
||||
while (0, 1) != StateSummary()[:2]:
|
||||
while (0, 1) != StateSummary():
|
||||
time.sleep(0.1)
|
||||
attempts += 1
|
||||
if attempts == max_attempts_before_failing:
|
||||
break
|
||||
assert (0, 1) == StateSummary()[:2]
|
||||
assert (0, 1) == StateSummary()
|
||||
|
||||
ray.shutdown()
|
||||
subprocess.Popen(["ray", "stop"]).wait()
|
||||
|
||||
Reference in New Issue
Block a user