简体   繁体   中英

Do Periodic & Repeated Jobs keep the same Job ID when repeated? Redis RQ-Scheduler

Let's say I had a job which is scheduled to run every 3 hours.

job = scheduler.schedule(
    scheduled_time=datetime.utcnow(),
    func=func,
    interval=10800,
    repeat=None
)

jobID = job.id

On the fifth time it runs, will it have the same Job ID as it does on the first time it's added to the scheduler - or does it change?

in short no it will not. You will infact notice that even if you job has the same date time object upto the microsecond level, it still throws a different job ID.

Heres my implementation and experience

def test():
      print("HELLO")

today=datetime.datetime.today()
today=today.replace(hour=10,minute=15,second=0,microsecond=0)
s1=Scheduler(connection=Redis())


print(today)
s1.schedule(scheduled_time=today,func=test,args=[],interval=10,repeat=None)

jobs1=s1.get_jobs()

for job in jobs1:
      #s1.cancel(job)
      print("first",job,job.id)


And heres the output:

2022-01-15 10:15:00
first <Job 3a7321d9-8703-4ee4-879c-b0e9f8bdfabe: __main__.test()> 3a7321d9-8703-4ee4-879c-b0e9f8bdfabe
first <Job 59a2cafe-e784-401e-9dcf-deb2da59b20a: __main__.test()> 59a2cafe-e784-401e-9dcf-deb2da59b20a
first <Job eccdf669-1b5d-4a42-aa72-23fa8b09e4bb: __main__.test()> eccdf669-1b5d-4a42-aa72-23fa8b09e4bb

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM