dbader / schedule

Python job scheduling for humans.
https://schedule.readthedocs.io/
MIT License
11.73k stars 959 forks source link

schedule to stop job which started with scheduling #500

Open Vernadskii opened 2 years ago

Vernadskii commented 2 years ago

Hi, I have researched issues but didn't find related issues with this. (https://github.com/dbader/schedule/issues/160) <-- is it better to create custom time checker in job and use schedule.CancelJob? (https://github.com/dbader/schedule/pull/226) <-- It looks like what i need, if i right understand it could be some think like this: job = schedule.every().day.at("00:00").do(start_logging()).stop("23:59") Thank you!

Vernadskii commented 2 years ago

Or i think one of the possible solution may be some think like this sample code:

if __name__ == "__main__":
    job = schedule.every().day.at("00:00").do(start_logging())
    while True:
        jobs = schedule.get_running_jobs()   # which return list, for example
        if len(jobs) > 1:
              jobs[0].kill()    # stop previous job