【发布时间】:2020-12-26 23:31:27
【问题描述】:
我在注册任务时遇到问题。这是我的代码,请帮忙。
task.py
from celery_app import app
from celery import chord
from celery import signature
@app.task(bind=True)
def send_email(self):
chorded_tasks = chord(get_expired_users.s(),notify.s()) #these tasks actually exist#
chorded_tasks.get()
runthis.py
import celeryconfig
from celery import Celery
import os
celery = Celery()
celery.config_from_object("celeryconfig")
project_name = os.path.basename(os.getcwd())
celery.send_task(
"tasks.send_email".format(project_name),
kwargs={
},
args={
},
上面的代码块是我正在运行的。它会运行良好,但实际上不会执行任务。我还有一个文件可以按计划运行它,而且效果也很好。我只是不明白为什么它不会运行实际任务
【问题讨论】:
-
看起来
"tasks.send_email".format(project_name)缺少格式字符串占位符——可能是在尝试将代码匿名化为可共享示例时出错?我希望project_name会被丢弃。 -
这是我的错误,需要项目名称而不是问题。对于那个很抱歉。我更担心我格式化和弦或和弦任务的方式
-
如果你能帮我解决错误`AttributeError: type object 'chord' has no attribute 's'`
标签: python celery scheduled-tasks chord