2

I am using celery 4.0 and was following this site. http://docs.celeryproject.org/en/latest/userguide/tasks.html#blog-tasks-py

views.py

task = test2.delay(document.name, document.id)

Tasks.py

@shared_task(name="test2")
def test2(param, job_id):
    return 'The test task executed with argument "%s" ' % param

However, it throws an exception TypeError: test2() takes exactly 1 argument (2 given). This is funny since i have 2 arguments and it works in the site i shown.

2
  • 3
    I just tried your code and it works fine and the minimal code posted here works fine. You probably have a messed up import (i.e., test2 defined in multiple places) or a stray .pyc file lying around. Commented Jan 12, 2017 at 0:01
  • 1
    @2ps I think i forgot to restart celery after modifying my tasks file. I guess this is why it threw the error. Thanks. Commented Jan 12, 2017 at 2:37

1 Answer 1

3

For folks that stumble upon this in the future;

You probably forgot to restart celery, friend!

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.