0

I want my script to run every n minutes starting from NOT NOW, but rather starting from the time I specified. When I do:

def periodic(scheduler, interval, action, actionargs=()):
     schedule_data_update.enterabs(interval, 1, periodic,
                (scheduler, interval, action, actionargs))
     action(*actionargs)
     logging.info('Running scheduled repeated updates') 

periodic(schedule_data_update, 120.0 , data_runner)

Above 120.0 is 2 minutes, when i am running it - it is running data_runner() every 2 minutes starting from now. However, when i replace that 120.0 with some other time and run it

repeater = int(update['update_interval']) + 120.0 
periodic(schedule_data_update, repeater  , data_runner)

where

int(update['update_interval']) == 1658746706.0

and

int(update['update_interval']) + 120.0 == 1658746826.0

it's running at the exact time I want it to run, but it is looping without stopping

Here are my loggings:

2022-07-25 16:56:22,265:INFO:Running scheduled repeated updates
2022-07-25 16:56:23,897:INFO:Running scheduled repeated updates
2022-07-25 16:56:25,341:INFO:Running scheduled repeated updates
2022-07-25 16:56:26,971:INFO:Running scheduled repeated updates
......
a lot more... (every other second)

My desired end result is:

2022-07-25 16:56:22,265:INFO:Running scheduled repeated updates
2022-07-25 16:58:22,265:INFO:Running scheduled repeated updates
#EVERY 2 MINUTES starting the time i specified above (repeater)

NOTE: I am required to use SCHED library and not anything else

  • Does this answer your question? [Schedule a repeating event in Python 3](https://stackoverflow.com/questions/2398661/schedule-a-repeating-event-in-python-3) – Dominik Stańczak Jul 26 '22 at 06:32
  • This is exactly where i got the code snippet from. I am trying to adopt it into my app. Like i said above, i want it to run not in the moment, rather after X amount of time which i specify. So not 2 miutes (120) but every variable REPEATER amount of time. – MuhammedTech Jul 26 '22 at 06:51

0 Answers0