【发布时间】:2019-02-02 00:52:45
【问题描述】:
我使用schedule 库每 X 秒调度一个函数:
我想要的是在单独的线程上运行这个函数。我在有关如何Run the scheduler in a separate thread 的文档中找到了这一点,但我不明白他做了什么。
有没有人可以向我解释如何做到这一点?
更新:
这是我试过的:
def post_to_db_in_new_thread():
schedule.every(15).seconds.do(save_db)
t1 = threading.Thread(target=post_to_db_in_new_thread, args=[])
t1.start()
【问题讨论】:
-
向我们展示您的代码,到目前为止您尝试过什么?
-
问题已更新
标签: python python-3.x schedule