🐛 fix(process.py): remove unnecessary session_id parameter in build_sorted_vertices function calls
🐛 fix(endpoints.py): remove unused import and type hinting to improve code readability and maintainability 🐛 fix(endpoints.py): fix incorrect import statement for TaskService 🐛 fix(endpoints.py): fix incorrect return value for get_task_status function ✨ feat(endpoints.py): add test case for async task processing to validate task completion and result
This commit is contained in:
parent
8d1bff38fe
commit
fa1ebea378
4 changed files with 63 additions and 10 deletions
|
|
@ -1,3 +1,6 @@
|
|||
import time
|
||||
|
||||
|
||||
def run_post(client, flow_id, headers, post_data):
|
||||
response = client.post(
|
||||
f"api/v1/process/{flow_id}",
|
||||
|
|
@ -6,3 +9,19 @@ def run_post(client, flow_id, headers, post_data):
|
|||
)
|
||||
assert response.status_code == 200, response.json()
|
||||
return response.json()
|
||||
|
||||
|
||||
# Helper function to poll task status
|
||||
def poll_task_status(client, headers, task_id, max_attempts=20, sleep_time=1):
|
||||
for _ in range(max_attempts):
|
||||
task_status_response = client.get(
|
||||
f"api/v1/task/{task_id}/status",
|
||||
headers=headers,
|
||||
)
|
||||
if (
|
||||
task_status_response.status_code == 200
|
||||
and task_status_response.json()["status"] == "SUCCESS"
|
||||
):
|
||||
return task_status_response.json()
|
||||
time.sleep(sleep_time)
|
||||
return None # Return None if task did not complete in time
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue