【发布时间】:2017-05-03 12:03:24
【问题描述】:
我是 Django 和 django-background-tasks 包的新手。
我面临一个问题,除非我强制运行命令 process_tasks,即 python manage.py process_tasks,否则我无法执行/启动后台任务。我想在不运行process_tasks 命令的情况下执行/启动后台任务。
settings.py
MAX_ATTEMPTS=1
BACKGROUND_TASK_RUN_ASYNC = True
tasks.py
from background_task import background
#included necessary packages for SMTP
@background(schedule=5)
def test():
#send mail to some ids
views.py
def index(request):
test(schedule=5)
return HttpResponse("Hello, world. ")
忽略我的逻辑。
【问题讨论】:
标签: django multithreading python-2.7 background-task