【发布时间】:2021-12-23 15:57:13
【问题描述】:
我正在尝试在 Tornado 中使用 IOLoop 定期运行一个函数。但是,下面的代码会报错吗?
TypeError: 不支持的截止日期 datetime.datetime(2021, 11, 11, 0, 35, 49, 445200)
from tornado.ioloop import IOLoop
import datetime
def schedule_next_email():
# t = datetime.date.today() + datetime.timedelta(seconds=10)
t = datetime.datetime.now() + datetime.timedelta(seconds=10)
# t2 = datetime.datetime.combine(t, datetime.time.min)
def wrapper():
print('test')
schedule_next_email()
IOLoop.current().add_timeout(t, wrapper) # Error
schedule_next_email()
参考:How to start Tornado periodic callback at a specific time?
回溯(最近一次通话最后): 文件“”,第 1 行,在 文件“”,第 8 行,在 schedule_next_email 文件“C:\Users\...\anaconda3\lib\site-packages\tornado\ioloop.py”,第 585 行,在 add_timeout raise TypeError("不支持的最后期限 %r" % 最后期限) TypeError: 不支持的截止日期 datetime.datetime(2021, 11, 11, 0, 47, 28, 944375)【问题讨论】: