Reputation: 15
As my title, I dont know how to update params when I reschedule my old job, show my code below:
import os
from apscheduler.schedulers.background import BackgroundScheduler
def test(s):
print(s)
if __name__ == '__main__':
scheduler = BackgroundScheduler()
scheduler.add_job(test, 'interval', seconds=3, args=['old params'], id="y")
print('Press Ctrl+{0} to exit'.format('Break' if os.name == 'nt' else 'C'))
try:
scheduler.start()
except (KeyboardInterrupt, SystemExit):
pass
# while True:
scheduler.reschedule_job("y", trigger="interval", seconds=10)
while True:
pass
In the period of add_job
, I could use args send params inside, but when I wanna update my job, I use reschedule_job
, yes, I saw offical docs that it works, but I dont know how to update my old params old params to new params new params in the period of reschedule_job
Getting help!!! Waitting for you online thank you
Upvotes: 0
Views: 2050
Reputation: 202
from the source code. it seems that
reschedule_job
can not modify other parameters.
you can use modify
instead of reschedule_job
example:
scheduler = BackgroundScheduler()
scheduler.add_job(test, 'interval', seconds=3, args=['old params'], id="y")
job = scheduler.get_job(job_id="y")
job.modify(
trigger='interval',
seconds=10
)
Upvotes: 1