Python Forum
something i noticed about the "schedule" module
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
something i noticed about the "schedule" module
#1
im new to python. using 3.7 atm. i just finished a SCADA auto fault reporting script (works off of a monitoring website's frontend). i've scheduled the program to run every 30 minutes.
schedule.every(30).minutes.run(abcd_1)
but i noticed that it the timer for 30 minutes only starts after the program has run its course. so if the first instance starts at 9:00, the second one will start at 9:32, then 10:04, 10:36 etc. is there a way to have the script run at every 30 minute mark accurately without resorting to writhing
schedule.every().day.at("9:00").do(abcd_1)
48 times?
Reply
#2
I guess you refer to schedule module from PyPI.
You can check their answer to your question:
Quote:How can I make sure long-running jobs are always executed on time?

Schedule does not account for the time it takes the job function to execute. To guarantee a stable execution schedule you need to move long-running jobs off the main-thread (where the scheduler runs). See “How to execute jobs in parallel?” in the FAQ for a sample implementation.
Another option is to look at APScheduler package which has BackgroundScheduler
Yet another approach is to use OS scheduler tool like cron or TaskScheduler.
And finally, to be technically correct to schedule each job separately will take 2 or max 3 lines with a loop, no need of 48 lines. :-)
If you can't explain it to a six year old, you don't understand it yourself, Albert Einstein
How to Ask Questions The Smart Way: link and another link
Create MCV example
Debug small programs

Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Cancelling previous schedule cosmarchy 2 2,795 Sep-15-2021, 04:55 PM
Last Post: Larz60+
  Hosting a script on a VPS, and on a schedule? oldguy 0 2,955 Mar-13-2021, 02:46 AM
Last Post: oldguy
  How to schedule Jupyter Notebooks with Papermill wendysling 0 2,510 Jun-11-2019, 05:53 PM
Last Post: wendysling
  schedule module conundrum wgovideo 11 4,339 May-29-2019, 06:39 PM
Last Post: wgovideo
  I got a problem with python schedule darktitan 2 3,502 Sep-22-2018, 12:49 PM
Last Post: darktitan
  Schedule with other processing RValentim 7 3,982 Jul-10-2018, 12:57 PM
Last Post: RValentim
  How to convert Schedule to APScheduler module? penguin9 2 3,774 May-03-2018, 12:44 PM
Last Post: penguin9
  Creating a schedule program ndplokkaar 4 3,960 Nov-23-2017, 04:21 PM
Last Post: ndplokkaar

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020