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):
8383 @admin .display (boolean = True , description = _ ('is scheduled?' ))
8484 def is_scheduled (self ) -> bool :
8585 """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
8787 return False
88+ # check whether job_id is in scheduled/enqueued/active jobs
8889 scheduled_jobs = self .rqueue .scheduled_job_registry .get_job_ids ()
8990 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 :
9298 self .job_id = None
9399 super (BaseJob , self ).save ()
94100 return res
You can’t perform that action at this time.
0 commit comments