Skip to content

Commit 5d9fe22

Browse files
Merge pull request #1124 from syucream/fix/simplify-job-more
Simplify some remaining entry tasks additionally
2 parents 196264b + 5c2f3e3 commit 5d9fe22

File tree

3 files changed

+173
-195
lines changed

3 files changed

+173
-195
lines changed

airone/lib/job.py

+10-4
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
11
import functools
22
from typing import Any, Callable
33

4+
from acl.models import ACLBase
45
from job.models import Job, JobStatus
56

67

78
def may_schedule_until_job_is_ready(
8-
func: Callable[[Any, Job], JobStatus | tuple[JobStatus, str] | None],
9+
func: Callable[[Any, Job], JobStatus | tuple[JobStatus, str, ACLBase | None] | None],
910
):
1011
@functools.wraps(func)
1112
def wrapper(kls, job_id: int):
@@ -18,15 +19,20 @@ def wrapper(kls, job_id: int):
1819

1920
try:
2021
# running Job processing
21-
ret: JobStatus | tuple[JobStatus, str] | None = func(kls, job)
22+
ret: JobStatus | tuple[JobStatus, str, ACLBase | None] | None = func(kls, job)
2223
except Exception:
2324
ret = JobStatus.ERROR
2425

2526
# update Job status after finishing Job processing
2627
if isinstance(ret, JobStatus):
2728
job.update(status=ret)
28-
elif isinstance(ret, tuple) and isinstance(ret[0], JobStatus) and isinstance(ret[1], str):
29-
job.update(status=ret[0], text=ret[1])
29+
elif (
30+
isinstance(ret, tuple)
31+
and isinstance(ret[0], JobStatus)
32+
and isinstance(ret[1], str)
33+
and isinstance(ret[2], ACLBase | None)
34+
):
35+
job.update(status=ret[0], text=ret[1], target=ret[2])
3036
elif not job.is_canceled():
3137
job.update(JobStatus.DONE)
3238

0 commit comments

Comments
 (0)