【发布时间】:2019-09-19 14:53:19
【问题描述】:
我一直在寻找一种解决方案来获取在预定时间执行的函数的返回值。这是一个示例函数。
def get_data(dir):
df = pd.DataFrame()
file_name = "nofile"
# The rest of the body of the code executes and updates the two variables df and file_name
return df, file_name
我想做的是将这个功能安排在早上 6:00。如果在上午 6:00 执行“get_data()”后 _file_name_ 仍为“nofile”,则应在下午 6:00 重新执行该函数。就这样
def sched():
# Schedule at 6 AM
# Here I cannot get the file_name as return value of get_data()
if file_name == "nofile":
# Schedule at 6 PM
file_name = "nofile"
我不知道如何使用 APScheduler。请帮忙。
【问题讨论】:
-
如果您能提供一些为 APScheduler 编写的代码,将会很有帮助。 This 是一个很好的例子,说明有人可以就他们的问题寻求帮助。您可以参考他们的代码,看看是否可以尝试执行。
-
你说“# Here I cannot get the file_name as return value of get_data()”是什么意思?为什么不能在这里打电话给
df, file_name = get_data(...)?
标签: python schedule apscheduler