所以我的任务在某个时间每天发生三次,需要执行。
我已经设置了使用名为日程表
的软件包执行此操作的代码Power query & power pivot - empty table and clearing pivot
我喜欢这个,我可以说,每天凌晨3点运行,或类似的东西。
然而,问题是,我希望我的其他代码同时运行,而不是陷入与运行时间表相同的循环中
现在,它看起来像是:
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):
schedule.every().day.at(firstTime).do(archerPull)
schedule.every().day.at(secondTime).do(archerPull)
schedule.every().day.at(thirdTime).do(archerPull)
schedule.every().day.at(fourthTime).do(archerPull)
schedule.every().day.at(fivthTime).do(archerPull)
schedulingTasks("13:46", "13:47", "13:48", "13:49", "13:50")
while True:
schedule.run_pending()
time.sleep(1)
正如您所看到的,循环将永远为True,因此每天运行调度程序。但是,如果我想将其他东西与它集成在一起,它还能永远循环吗?
我希望任务是单独发生的(对于它来说是异步的)
请帮帮我,谢谢!
答案 0 :(得分:0)
是的,我在问这个问题的那天就想到了这个问题
我使用ap-scheduler来做这个,我的webapp in flask运行良好,而我需要的背景任务工作很棒