bulk-part-jobs, and scgi retries
This commit is contained in:
@@ -236,9 +236,9 @@ def list_jobs(limit: int = 200, offset: int = 0):
|
||||
|
||||
def cancel_job(job_id: str) -> bool:
|
||||
row = _job_row(job_id)
|
||||
if not row or row["status"] in {"done", "cancelled"}:
|
||||
if not row or row["status"] not in {"pending", "running"}:
|
||||
return False
|
||||
# Awaryjne anulowanie: pending, running i failed można oznaczyć jako cancelled z poziomu użytkownika.
|
||||
# Note: Emergency cancel ma sens tylko dla niedokonczonych zadan; failed/done zostaja tylko do retry albo czyszczenia logow.
|
||||
_set_job(job_id, "cancelled", finished=True)
|
||||
_emit("job_update", {"id": job_id, "status": "cancelled"})
|
||||
return True
|
||||
@@ -254,7 +254,7 @@ def emergency_clear_jobs() -> int:
|
||||
# Awaryjne czyszczenie: najpierw zamyka aktywne zadania jako cancelled, potem czyści całą listę job logów.
|
||||
now = utcnow()
|
||||
with connect() as conn:
|
||||
conn.execute("UPDATE jobs SET status='cancelled', error='Emergency cancelled by user', finished_at=COALESCE(finished_at, ?), updated_at=? WHERE status IN ('pending', 'running', 'failed')", (now, now))
|
||||
conn.execute("UPDATE jobs SET status='cancelled', error='Emergency cancelled by user', finished_at=COALESCE(finished_at, ?), updated_at=? WHERE status IN ('pending', 'running')", (now, now))
|
||||
cur = conn.execute("DELETE FROM jobs")
|
||||
deleted = int(cur.rowcount or 0)
|
||||
_emit("job_update", {"status": "cleared", "emergency": True})
|
||||
|
||||
Reference in New Issue
Block a user