Package: precise-scheduler
Python job scheduling for humans. Run Python functions (or any other callable) periodically using a friendly syntax.A simple to use API for scheduling jobs, made for humans.In-process scheduler for periodic jobs. No extra processes needed!Very lightweight and no external dependencies.Excellent test coverage.Usage$pipinstallprecise-schedulerimportdatetimeimportprecise_schedulerimporttimeimportpausescheduler=precise_scheduler.Scheduler(schedule_base="last_schedule")#scheduler = precise_scheduler.Scheduler(schedule_base="last_run_start")#scheduler = precise_scheduler.Scheduler()defgreet(name):print("Hello",name,datetime.datetime.now())time.sleep(1)scheduler.every(2).seconds.do(greet,name="Alice")scheduler.every(4).seconds.do(greet,name="Bob")fromprecise_schedulerimportevery,repeat@repeat(scheduler.every(5).seconds,"World")@repeat(scheduler.every().day,"Mars")defhello(planet):print("Hello",planet,datetime.datetime.now())time.sleep(0.5)whileTrue:pause.until(scheduler.get_next_run())scheduler.run_pending()# Hello Alice 2023-03-02 12:24:31.000249# Hello Alice 2023-03-02 12:24:33.000094# Hello Bob 2023-03-02 12:24:34.001463# Hello World 2023-03-02 12:24:35.003073# Hello Alice 2023-03-02 12:24:35.503961# Hello Alice 2023-03-02 12:24:37.000157# Hello Bob 2023-03-02 12:24:38.001703# Hello Alice 2023-03-02 12:24:39.003366# Hello World 2023-03-02 12:24:40.004778# Hello Alice 2023-03-02 12:24:41.000172Comparison with scheduleThis test will show how the old module (schedule ) drifts from the schedule on each execution and the new version is accurate to the schedule.The small microseconds shown in time is the time it takes to execute the print statement,
call of function and slight difference of time.sleep(0.001) , which is common for both implementations$pipinstallprecise-scheduler$pipinstallscheduleimportdatetimeimportprecise_schedulerimporttimeimportschedulescheduler=precise_scheduler.Scheduler(schedule_base="last_schedule")schedule_old=schedule.Scheduler()defgreet(name):print("Hello",name,datetime.datetime.now())time.sleep(1)scheduler.every(3).seconds.do(greet,name="precise_scheduler")schedule_old.every(3).seconds.do(greet,name="schedule")whileTrue:time.sleep(0.001)scheduler.run_pending()schedule_old.run_pending()# Hello precise_scheduler 2023-03-08 11:16:42.000479# Hello schedule 2023-03-08 11:16:43.001039# Hello precise_scheduler 2023-03-08 11:16:45.000918# Hello schedule 2023-03-08 11:16:47.002968# Hello precise_scheduler 2023-03-08 11:16:48.004551# Hello precise_scheduler 2023-03-08 11:16:51.000129# Hello schedule 2023-03-08 11:16:52.001413BackgroundThis package is a slight improvement ofhttps://github.com/dbader/scheduleThe changes arePreviously the calculation of next schedule was based on end of execution. Now you can also select based on start of last execution start or based on schedule (will be same unless you have a on demand execution).All schedules will be truncated to 0 microseconds.The code is updated to newer Pep requirementsThe  reason for starting this package is the above updates are really needed and the package has not being updated for long and is under MIT licence.For now the documentation remains the same only difference is mentioned below in code example and you can check out examples folder for python filesDocumentationprecise_scheduler’s documentation lives atprecise_scheduler.readthedocs.io.MetaBibin Varghese -@bibinvargheset-bibinvargheset@gmail.comThis package is a based onhttps://github.com/dbader/scheduleInspired byAdam Wiggins’article“Rethinking Cron”and theclockworkRuby module.Distributed under the MIT license. SeeLICENSE.txtfor more information.https://github.com/bibinvargheset/precise_scheduler