1
1
import functools
2
2
from typing import Any , Callable
3
3
4
+ from acl .models import ACLBase
4
5
from job .models import Job , JobStatus
5
6
6
7
7
8
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 ],
9
10
):
10
11
@functools .wraps (func )
11
12
def wrapper (kls , job_id : int ):
@@ -18,15 +19,20 @@ def wrapper(kls, job_id: int):
18
19
19
20
try :
20
21
# 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 )
22
23
except Exception :
23
24
ret = JobStatus .ERROR
24
25
25
26
# update Job status after finishing Job processing
26
27
if isinstance (ret , JobStatus ):
27
28
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 ])
30
36
elif not job .is_canceled ():
31
37
job .update (JobStatus .DONE )
32
38
0 commit comments