Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

use scheduler.modify_job() #132

Open
Deep-sea-boy opened this issue Oct 20, 2020 · 4 comments
Open

use scheduler.modify_job() #132

Deep-sea-boy opened this issue Oct 20, 2020 · 4 comments

Comments

@Deep-sea-boy
Copy link

When I used this method to change the seconds parameter of a job , it didn't work。It still executed the old seconds parameter .
how can i reload the scheduler or job with the new parameter

@viniciuschiele
Copy link
Owner

Can you show me how you called modify_job?

@Deep-sea-boy
Copy link
Author

Deep-sea-boy commented Oct 21, 2020

        for job in scheduler.get_jobs():
            if job.id == "check_asset_online":
                scheduler.modify_job(job.id, trigger='interval', seconds=600)   # old seconds is 33

when i run this code , seconds was change ,
for job in scheduler.get_jobs():
print(job.id)
print(job.trigger) # now seconds is 600

the new trigger shows the new seconds ,but in the log ,it shows :
apscheduler.executors.default:Job "check_asset_online (trigger: interval[0:00:33], next run at: 2020-10-21 08:48:05 CST)" executed successfully
apscheduler.executors.default:Job "check_asset_online (trigger: interval[0:00:33], next run at: 2020-10-21 08:48:38 CST)" executed successfully
....

how can i reload the scheduler?

@mvirnoche
Copy link

In the normal APScheduler I hit a bug doing modfiy_job() not realizing I actually need job.reschedule(trigger)

from apscheduler.triggers.interval import IntervalTrigger
_trigger = IntervalTrigger(minutes=int(minutes))
scheduler.get_job.reschedule(_trigger)

@vglaiju
Copy link

vglaiju commented Jul 6, 2022

Reproduced same issue @Deep-sea-boy , @mvirnoche pease advise if we should still use native APS reschedule still or you have a new implementation in flask-APS for reschedule()

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants