user2537952
user2537952

Reputation: 31

celery chain kwargs example from docs

This example exists in the celery documentation.

>>> 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='[email protected]')

As you can see the kwargs are implicitly available in the create_user subtask. While I assume that the returned user object provides the values required for import and send,for the life of me, I can not figure out how create_user gets access to kwargs in this example. When I mock this out with a create_user task it always gets 0 arguments, I assume this is because there are no arguments passed to .s(). Does anyone know how to access the kwargs in create_user?

Here is my test code:

@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")

Results:

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

Thanks.

edit: added test code

Upvotes: 1

Views: 1140

Answers (1)

user2537952
user2537952

Reputation: 31

Created an issue on the celery github and it appears this is a bug.

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

Upvotes: 1

Related Questions