user3196126 user3196126 - 1 year ago 64
Python Question

Python, doing task 3 times a day while other stuff is happening?

So I have a task that occurs three times a day at a certain time that needs to be executed.

I've set up code that does this using a package called Schedule

What I like about this is I can say, run at 3:00AM every day, or something similar.

However, the issue is, I want my other code to be running at the same time, and not be stuck in the same loop that the Schedule is running in

So right now, it looks something like:

def archerPull():
#insert code for calling archer pull here

with open("LogsForStuffPull.txt", "a") as myfile:
myfile.write("time: " + time.ctime(time.time()))

#this is code for scheduling job to do every day

def schedulingTasks(firstTime, secondTime, thirdTime, fourthTime, fivthTime):


schedulingTasks("13:46", "13:47", "13:48", "13:49", "13:50")

while True:

So as you can see, the loop will be True forever, and therefore run the scheduler everyday. But if I want to integrate other stuff with it, will it also be looped forever?

I want the tasks to be indivitual occuring (is asynchronous the word for it)

Please help me out, thanks!

Answer Source

Yeah, I figured this out the same day I asked this question

I used ap-scheduler to do this, my webapp in flask is running well while the backgrounds tasks I needed work great

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download