Python 在新线程中运行调度函数

Python 在新线程中运行调度函数,python,python-3.x,schedule,Python,Python 3.x,Schedule,我使用库每X秒安排一个函数: 我想要的是在单独的线程上运行这个函数。我在如何操作的文档中发现了这一点,但我不明白他做了什么 有人能告诉我怎么做吗 更新: 这就是我所尝试的: 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() 所以我会回答我自己的

我使用库每X秒安排一个函数:

我想要的是在单独的线程上运行这个函数。我在如何操作的文档中发现了这一点,但我不明白他做了什么

有人能告诉我怎么做吗

更新

这就是我所尝试的:

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()

所以我会回答我自己的问题

import threading
import time
import schedule 

def run_threaded(job_func):
    job_thread = threading.Thread(target=job_func)
    job_thread.start()


    schedule.every(15).seconds.do(run_threaded, save_db)



while 1:
    schedule.run_pending()
    time.sleep(1) 

向我们展示您的代码,到目前为止您尝试了什么?问题已更新