in modules/python/csi/csi.py [0:0]
def wait_for_condition(check_function, target, comparison="gte", interval=1):
"""
Wait for a condition using a given check function.
The check function should return a list of items.
The condition is satisfied when the length of the list meets the target.
"""
while True:
current_list = check_function()
current = len(current_list)
print(f"Current: {current}, Target: {target}")
if (comparison == "gte" and current >= target) or (comparison == "lte" and current <= target):
return current
time.sleep(interval)