dbader / dbader/schedule

run only once - : schedule.at('22:30').do(any_job)

Open
#408 9 comments 4 reactions 0 assignees View on GitHub
enhancement
Dominant language
Python
Stars
12.3k
Forks
999
PR merge metrics
No merged PRs in 30d

Description

To run a job only once the manual says:
```
def job_that_executes_once():
# Do some work ...
return schedule.CancelJob

schedule.every().day.at('22:30').do(job_that_executes_once)
```
The problem with this implementation is that in case the `job_that_executes_once` is missing the `return 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)` ?

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.