File tree Expand file tree Collapse file tree 1 file changed +9
-3
lines changed Expand file tree Collapse file tree 1 file changed +9
-3
lines changed Original file line number Diff line number Diff line change @@ -83,12 +83,18 @@ def callable_func(self):
83
83
@admin .display (boolean = True , description = _ ('is scheduled?' ))
84
84
def is_scheduled (self ) -> bool :
85
85
"""Check whether job is queued/scheduled to be executed"""
86
- if not self .job_id :
86
+ if not self .job_id : # no job_id => is not scheduled
87
87
return False
88
+ # check whether job_id is in scheduled/enqueued/active jobs
88
89
scheduled_jobs = self .rqueue .scheduled_job_registry .get_job_ids ()
89
90
enqueued_jobs = self .rqueue .get_job_ids ()
90
- res = (self .job_id in scheduled_jobs ) or (self .job_id in enqueued_jobs )
91
- if not res : # self.job_id is not None
91
+ active_jobs = self .rqueue .started_job_registry .get_job_ids ()
92
+ res = ((self .job_id in scheduled_jobs )
93
+ or (self .job_id in enqueued_jobs )
94
+ or (self .job_id in active_jobs ))
95
+ # If the job_id is not scheduled/enqueued/started,
96
+ # update the job_id to None. (The job_id belongs to a previous run which is completed)
97
+ if not res :
92
98
self .job_id = None
93
99
super (BaseJob , self ).save ()
94
100
return res
You can’t perform that action at this time.
0 commit comments