Issue with python schedule library

Viewed 120

I'm trying to use the python schedule library to run a script every day at midnight on GMT-7. I'm assuming it's using GMT time, or system time, so I set it to run at 17:00 every day, but for some reason is starts straight away every time I run it. This is the code I am using.

schedule.every().day.at("17:00").do(getRegressionData(subredditList))
while True:
    schedule.run_pending()
    time.sleep(1)

Any ideea what might be causing this?

1 Answers

You are currently explicitly calling the getRegressionData function with the argument subredditList and pass the return value to do.

As per the docs, do accepts a function and optional positional and keyword arguments. It then calls the function for you at the desired time with the provided arguments.

Use do(getRegressionData, subredditList).

Related