为什么Python芹菜任务尽管只调用了一次,却被多次调用
我有这个密码。调用芹菜任务,这是一个Python脚本。想知道为什么我在执行死刑时收到3封电子邮件 test()是否调用了3次为什么Python芹菜任务尽管只调用了一次,却被多次调用,python,celery,Python,Celery,我有这个密码。调用芹菜任务,这是一个Python脚本。想知道为什么我在执行死刑时收到3封电子邮件 test()是否调用了3次 @client.task() def test(id): call(["python", "/script.py", "-t", "test", "-s", "test", "-o", &quo
@client.task()
def test(id):
call(["python", "/script.py", "-t",
"test", "-s", "test", "-o", "real", "-i", "{:s}".format(id)])
message = Mail(
from_email='from',
to_emails='to',
subject="subject {:s}".format(id),
html_content='<strong>text</strong>')
try:
sg = SendGridAPIClient(os.environ.get('SENDGRID_API_KEY'))
response = sg.send(message)
print(response.status_code)
print(response.body)
print(response.headers)
except Exception as e:
print(e.message)
@app.route("/test", methods=['GET'])
@oidc.accept_token(True)
def testbyID():
id = request.args.get('id')
result = test.apply_async(args=[id], countdown=60)
return result.id
@client.task()
def测试(id):
调用([“python”,“/script.py”,“-t”,
“test”、“-s”、“test”、“-o”、“real”、“-i”、“{:s}”.format(id)])
信息=邮件(
from_email='from',
到"到",,
subject=“subject{:s}”。格式(id),
html_content='text)
尝试:
sg=SendGridAPIClient(os.environ.get('SENDGRID\u API\u KEY'))
响应=sg.send(消息)
打印(响应状态\ U代码)
打印(响应.正文)
打印(响应.标题)
例外情况除外,如e:
打印(电子邮件)
@app.route(“/test”,methods=['GET']))
@oidc.accept_令牌(真)
def testbyID():
id=request.args.get('id')
结果=测试。应用异步(args=[id],倒计时=60)
返回result.id
一旦任务被处理,我如何更正它以只收到一封电子邮件
更新1:
改成
task.delay()和get now任务立即执行,只收到1封电子邮件
还想知道如何让它与1封电子邮件异步执行吗