0

I just wrote a simple celery code,that will just add two number and print it,using celery..using the following code:

from scheduling.celery import app

*@app.task
def add(x, y):
    print("sum is "+str(x+y))*

But the problem is when i call this function using :

*add.apply_async((3, 4))*

there's a raise exception error saying that

> Task
> celerytasktest.simplecelerytask.add[bafe33b6-3329-406a-b5c0-43eee9228273]
> raised unexpected: TypeError("unhashable type: 'dict'",)

I tried two days to find out the problem,but failed.

I am using the celery version 3.1.9

Thanks in advance

Ankur Ankan
  • 2,953
  • 2
  • 23
  • 38
  • You are calling wrong your `add` function. Instead of `x, y`, you are adding `tuple`. Same problem describes [here](http://stackoverflow.com/questions/13264511/typeerror-unhashable-type-dict) – Valijon Jun 16 '14 at 05:37

2 Answers2

3

You should call your function like this:

function.apply_async(
args = [param1, param2, ...],
kwargs = {k : v}, ...})

With your add functions, the statement will be:

add.apply_async(args = [3,4])

You can check the documentation http://celery.readthedocs.org/en/latest/reference/celery.app.task.html#celery.app.task.Task.apply_async

xecgr
  • 5,095
  • 3
  • 19
  • 28
0

I was getting this same error when running celery as a daemon with the celery multi start command. Oddly enough, changing the name of one of my queues from q3 to q4 seems to be what fixed it.

Andrew
  • 897
  • 1
  • 9
  • 19