计划的作业执行两次,差异以纳秒为单位。我有一个任务如下task.py
def print_hello():
print("time-->",datetime.datetime.now())
print("hello")
def print_world():
print("time-->",datetime.datetime.now())
print("hello")
scheduler = BackgroundScheduler()
scheduler1 = BackgroundScheduler()
从应用程序文件夹中添加 app.py,包含以下代码行。
from django.apps import AppConfig
from datetime import date
class ExploitDataConfig(AppConfig):
name = 'exploit_data'
def ready(self):
from exploit_data import task
task.scheduler.add_job(task.print_hello, 'interval', minutes=5)
task.scheduler1.add_job(task.print_world, 'interval', minutes=5
task.scheduler.start()
task.scheduler1.start()
我要这个仅执行一次间隔5分钟。任何帮助都是值得赞赏的..
也许这可以帮助临时解决方案:
python manage.py runserver --noreload
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)