mirror of
https://github.com/wassname/ray.git
synced 2026-06-27 20:22:39 +08:00
Use wait_for_condition to reduce flakiness in test_queue.py::test_custom_resources (#13210)
This commit is contained in:
@@ -1,10 +1,9 @@
|
||||
import time
|
||||
|
||||
import pytest
|
||||
|
||||
import ray
|
||||
from ray.exceptions import GetTimeoutError, RayActorError
|
||||
from ray.util.queue import Queue, Empty, Full
|
||||
from ray.test_utils import wait_for_condition
|
||||
|
||||
|
||||
# Remote helper functions for testing concurrency
|
||||
@@ -206,9 +205,11 @@ def test_custom_resources(ray_start_regular_shared):
|
||||
|
||||
# Specify resource requirement. The queue should now reserve 1 CPU.
|
||||
Queue(actor_options={"num_cpus": 1})
|
||||
time.sleep(1)
|
||||
current_resources = ray.available_resources()
|
||||
assert "CPU" not in current_resources, current_resources
|
||||
|
||||
def no_cpu_in_resources():
|
||||
return "CPU" not in ray.available_resources()
|
||||
|
||||
wait_for_condition(no_cpu_in_resources)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
|
||||
Reference in New Issue
Block a user