-
Notifications
You must be signed in to change notification settings - Fork 972
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
run only once - : schedule.at('22:30').do(any_job) #408
Comments
Hi @helarsen, This has been proposed before in #39 and addressed in this comment specifically. It was also implemented in #184 and declined for the same reason. Your strong reasoning about hard-to-find bugs made me reconsider declining again. The fact that this has been proposed over and over throughout the years, and the relatively small impact of this change, it might be worth it to add... And also I like the looks of this 😍
Keeping this open and marking it as enhancement, no promises though ;) |
I would extend my suggestion:
This provides appealing symmetry. There cannot be any By the way - thumbs up to how professional the management of this library is! |
Thanks for the compliment 😊 In regards to when the first coming invocation should be; Could we just keep the scheduling system as is and cancel the job after the first invocation? Is there a need to re-define when the the 'next' job is? |
Sorry, I miss your point here:
What I suggest is that: |
Yes
No would be the short answers - hopefully just supplementing what I previously wrote |
Ah, I now understand your point;
This is how the scheduler currently works, so we can just re-use the current next-run calculations. Which makes this so much easier 😄 |
Yes the main difference to Further to the support of this enhancement:
|
Maybe when |
A workaround I'm using for this is adding a boolean (named once) as argument of the job function + adding "-once" after the job id in the tag: Then at the start of the job function i have:
Which prevents the job from executing another time after this first run. |
To run a job only once the manual says:
The problem with this implementation is that in case the
job_that_executes_once
is missing thereturn schedule.CancelJob
, you will get the job run every day at "22:30" where you did not expect this.This can be one of the very hard-to-find bugs which pops "out of the blue"
The term ".every().day." is misleading in this context but there is no way around it as of now.
The naive may try:
schedule.at('22:30').do(any_job)
AttributeError: module 'schedule' has no attribute 'at'
so it does not work.I would advocate for a method to schedule any job to run only once. But I don't know how this best fits the existing interface.
Maybe something like
schedule.once().at('22:30').do(any_job)
?The text was updated successfully, but these errors were encountered: