Stop only waiting validation tasks
This commit is contained in:
8
main.py
8
main.py
@@ -1,4 +1,4 @@
|
||||
"""Stop zhoukaile's active ModelHub XC validation tasks.
|
||||
"""Stop zhoukaile's waiting ModelHub XC validation tasks.
|
||||
|
||||
The service performs the stop requests once at startup and then stays alive so
|
||||
the strategy platform can probe it through ``/health`` and inspect ``/status``.
|
||||
@@ -31,7 +31,7 @@ MAX_RETRIES = int(os.environ.get("MAX_RETRIES", "3"))
|
||||
REQUEST_TIMEOUT = int(os.environ.get("REQUEST_TIMEOUT", "30"))
|
||||
|
||||
PAGE_SIZE = 100
|
||||
ACTIVE_STATUSES = {"waiting", "running", "pending", "processing", "queued"}
|
||||
STOPPABLE_STATUS = "waiting"
|
||||
|
||||
_shutdown = threading.Event()
|
||||
_state: dict[str, Any] = {
|
||||
@@ -89,7 +89,7 @@ def _login() -> str:
|
||||
|
||||
|
||||
def _current_task_ids() -> list[int]:
|
||||
"""Fetch every active task currently submitted by USER_ACCOUNT.
|
||||
"""Fetch every waiting task currently submitted by USER_ACCOUNT.
|
||||
|
||||
This intentionally queries the user-facing task page at run time. A static
|
||||
list becomes obsolete as soon as zhoukaile submits more validation tasks.
|
||||
@@ -114,7 +114,7 @@ def _current_task_ids() -> list[int]:
|
||||
data = result.get("data") or {}
|
||||
records = data.get("records") or []
|
||||
for record in records:
|
||||
if str(record.get("status", "")).lower() not in ACTIVE_STATUSES:
|
||||
if str(record.get("status", "")).lower() != STOPPABLE_STATUS:
|
||||
continue
|
||||
try:
|
||||
task_ids.append(int(record["taskId"]))
|
||||
|
||||
Reference in New Issue
Block a user