[Test][kv_offload] Fix flaky drain() helper in test_fs_tier.py (#48545)
Signed-off-by: Chaojun Zhang <chaojun.zhang@intel.com>
This commit is contained in:
@@ -91,24 +91,10 @@ def make_job(
|
||||
)
|
||||
|
||||
|
||||
def drain(tier: FileSystemTierManager, max_rounds: int = 100) -> list:
|
||||
"""
|
||||
Call get_finished_jobs() repeatedly until no new results arrive for 20
|
||||
consecutive rounds or max_rounds is reached.
|
||||
"""
|
||||
results = []
|
||||
idle = 0
|
||||
for _ in range(max_rounds):
|
||||
time.sleep(0.01)
|
||||
new = list(tier.get_finished_jobs())
|
||||
results.extend(new)
|
||||
if new:
|
||||
idle = 0
|
||||
else:
|
||||
idle += 1
|
||||
if idle >= 20:
|
||||
break
|
||||
return results
|
||||
def drain(tier: FileSystemTierManager) -> list:
|
||||
"""Block until all in-flight jobs finish, then collect results."""
|
||||
tier.drain_jobs()
|
||||
return list(tier.get_finished_jobs())
|
||||
|
||||
|
||||
def lookup_and_wait(
|
||||
|
||||
Reference in New Issue
Block a user