import timedef wait_for_jobs(client, collection_id, job_ids, poll_interval=2.0): pending = set(job_ids) while pending: statuses = client.get_agent_run_job_statuses(collection_id, list(pending)) for s in statuses: if s["status"] in ("completed", "canceled", "cancelling"): pending.discard(s["job_id"]) print(f"Job {s['job_id']}: {s['status']}") if pending: time.sleep(poll_interval) print("All jobs finished")
When using add_agent_runs with wait=True (the default), job polling is handled
automatically. You only need manual polling when wait=False.