Python-celery(v4.1.0)击败任务无法以参数编号错误运行

时间:2018-05-23 14:02:25

标签: python celery

我的目的是从MongoDB中提取任务配置以启动我的节拍任务导出(args)。但只有错误:export() takes 0 positional arguments but 15 were given,这是配置文件:

from celery.schedules import crontab
from exportUtils import MongodbUtils

broker_url = 'amqp://ops:123465@127.0.0.1:5672/tasks'
mongo_uri = "mongodb://task:task@localhost/task_config?authMechanism=SCRAM-SHA-1"
beat_schedule = {}

client = MongodbUtils(mongo_uri)
tasks = client.find("task_config", "cron_tasks", {"is_enabled": True})
client.close()
for task in tasks:
    crons = task["crontab_string"].split()
    schedule = crontab(hour=crons[0], minute=crons[1], day_of_week=crons[4], day_of_month=crons[2], month_of_year=crons[3])
    beat_schedule[task["task_name"]] = {
        'task': task["task_def"],
        'schedule': schedule,
        'args': (task["args"])
    }
print(beat_schedule)

任务导出():

@app.task
def export(paras):
    client = MySQLUtils(paras)
    cols, rows = client.execute_sql(paras["script"])
    export_to_xls(paras["output"], cols, rows)

我假设export()中的args为dict类型,beat_schedule应该如下所示,因为我在终端中将其打印出来:

{'test_demo': 
    {'task': 'tasks.export', 
     'schedule': <crontab: * */1 * * * (m/h/d/dM/MY)>, 
     'args': {'receivers': 'lizhi@qq.com', 
     'content': 'Welcome', 
     'output': 'export.xls'
     .....
    }
 }}

我已将出口(寄往)改为出口(**寄存),仍然没有运气,有人请帮忙吗?如果需要任何进一步的信息,也请告诉我。谢谢:)

0 个答案:

没有答案