python - 文档中的 celery 链 kwargs 示例

标签 python canvas celery chain keyword-argument

此示例存在于 celery 文档中。

>>> new_user_workflow = (create_user.s() | group(
...                      import_contacts.s(),
...                      send_welcome_email.s()))
... new_user_workflow.delay(username='artv',
...                         first='Art',
...                         last='Vandelay',
...                         email='art@vandelay.com')

如您所见,kwargs 在 create_user 子任务中隐式可用。虽然我假设返回的用户对象提供了导入和发送所需的值,但在我的一生中,我无法弄清楚 create_user 如何在这个示例中访问 kwargs。当我使用 create_user 任务模拟它时,它总是获得 0 个参数,我认为这是因为没有参数传递给 .s()。有谁知道如何访问create_user中的kwargs?

这是我的测试代码:

@app.task()
def create_user(*args, **kwargs):
    print args
    print kwargs
    return "foo"

@app.task()
def something_else(*args, **kwargs):
    print args
    print kwargs

test = chain(create_user.s(), something_else.s())
test.delay(username="test", password="testp")

结果:

()
{}
('foo',)
{}

谢谢。

编辑:添加测试代码

最佳答案

在 celery github 上创建了一个问题,看来这是一个错误。

https://github.com/celery/celery/issues/2695

关于python - 文档中的 celery 链 kwargs 示例,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31255048/

相关文章:

python - Celery 任务的finally 子句不执行,我该如何清理?

python - Canonical Celery 单文件 hello world

python - 错误消息 'No handlers could be found for logger "multiprocessing"' 使用 Celery

javascript - Canvas Shiny 星星背景性能问题

javascript - 裁剪缩小图像

javascript - 如何在每次点击移动图形时知道它的宽度和高度?

python - 通过 PyPDF2 合并两个 PDF,但出现错误 Unexpected destination '/__WKANCHOR_2'

python - python的帧缓冲模块

python - pyLucene安装

Python 3.5 字典比较