forked from mtusi2026/mtusi2026lab6
31 lines
670 B
Python
31 lines
670 B
Python
"""Operator replay of one failed job. A ready job is left unchanged."""
|
|
|
|
from __future__ import annotations
|
|
|
|
import asyncio
|
|
import sys
|
|
from uuid import UUID
|
|
|
|
from app import db, jobs
|
|
|
|
|
|
async def _run(job_id: UUID) -> int:
|
|
await db.connect()
|
|
try:
|
|
result = await jobs.replay(job_id)
|
|
finally:
|
|
await db.close()
|
|
print(result["result"])
|
|
return 0 if result["result"] in {"noop", "queued"} else 1
|
|
|
|
|
|
def main() -> None:
|
|
if len(sys.argv) != 2:
|
|
print("usage: python -m app.replay JOB_ID", file=sys.stderr)
|
|
raise SystemExit(2)
|
|
raise SystemExit(asyncio.run(_run(UUID(sys.argv[1]))))
|
|
|
|
|
|
if __name__ == "__main__":
|
|
main()
|