类型错误:关键字必须是字符串

时间:2017-07-26 10:37:51

标签: mongodb celery celerybeat

我想在celerybeat-mongo的帮助下使用python 2.7在celery中动态执行一些任务,因为我希望celery从mongo数据库动态地获取任务细节。 这是我的示例代码:

from celery import Celery

app = Celery('tasks', broker='redis://localhost')

app.config_from_object('celeryconfig')

@app.task
def add(x, y):
    return int(x) + int(y)

并根据celerybeat-mongo celerybeat-mongo

的文件

我的mongodb文件是

{
    "_id" : ObjectId("59786aa52f3dd74f7a2943d4"),
    "_cls" : "PeriodicTask",
    "name" : "Addition",
    "task" : "task.add",
    "enabled" : true,
    "interval" : {
        "every" : 1,
        "period" : "minute"
    },
    "args" : [
        "2",
        "5"
    ],
    "kwargs" : {
        "max_targets" : "100"
    }
}

当我尝试执行以下命令时:

celery beat -S celerybeatmongo.schedulers.MongoScheduler

它显示错误为 -

[2017-07-26 15:44:19,729: WARNING/MainProcess] File "/home/username/.venvs/cel/local/lib/python2.7/site-packages/celerybeatmongo/models.py", line 38, in schedule
[2017-07-26 15:44:19,730: WARNING/MainProcess] return celery.schedules.schedule(datetime.timedelta(**{self.period: self.every}))
[2017-07-26 15:44:19,730: WARNING/MainProcess] TypeError
[2017-07-26 15:44:19,730: WARNING/MainProcess] :
[2017-07-26 15:44:19,730: WARNING/MainProcess] keywords must be strings

我不明白它指向哪个关键字?

0 个答案:

没有答案