mirror of
https://github.com/wassname/ray.git
synced 2026-07-11 23:08:38 +08:00
Deflake test_env_with_subprocess.py (#11257)
This commit is contained in:
@@ -2,12 +2,12 @@
|
||||
import os
|
||||
import subprocess
|
||||
import tempfile
|
||||
import time
|
||||
|
||||
import ray
|
||||
from ray.tune import run_experiments
|
||||
from ray.tune.registry import register_env
|
||||
from ray.rllib.examples.env.env_with_subprocess import EnvWithSubprocess
|
||||
from ray.test_utils import wait_for_condition
|
||||
|
||||
|
||||
def leaked_processes():
|
||||
@@ -56,13 +56,11 @@ if __name__ == "__main__":
|
||||
},
|
||||
},
|
||||
})
|
||||
time.sleep(10.0)
|
||||
# Check whether processes are still running or Env has not cleaned up
|
||||
# the given tmp files.
|
||||
leaked = leaked_processes()
|
||||
assert not leaked, "LEAKED PROCESSES: {}".format(leaked)
|
||||
assert not os.path.exists(tmp1), "atexit handler not called"
|
||||
assert not os.path.exists(tmp2), "atexit handler not called"
|
||||
assert not os.path.exists(tmp3), "close not called"
|
||||
assert not os.path.exists(tmp4), "close not called"
|
||||
wait_for_condition(lambda: not leaked_processes(), timeout=30)
|
||||
wait_for_condition(lambda: not os.path.exists(tmp1), timeout=30)
|
||||
wait_for_condition(lambda: not os.path.exists(tmp2), timeout=30)
|
||||
wait_for_condition(lambda: not os.path.exists(tmp3), timeout=30)
|
||||
wait_for_condition(lambda: not os.path.exists(tmp4), timeout=30)
|
||||
print("OK")
|
||||
|
||||
Reference in New Issue
Block a user