Stop only waiting validation tasks

This commit is contained in:
zhouyuanxi
2026-07-25 15:30:17 +08:00
parent 4f0725332e
commit 1bdff3d2e8
2 changed files with 6 additions and 6 deletions

View File

@@ -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"]))