3

I'v just started to implement Django+Celery+RabbitMQ to do some backend tasks. I started with the example add(x, y) task to verify it was working then proceeded to place my existing utility methods in a Celery tasks module. The trouble is when I call my tasks they run fine but the client never gets the result.

>>> r = SyncUsers.delay()
>>> r.get()
... Hangs here forever
^C
... (Stack trace omitted)
KeyboardInterrupt
>>> r.successful()
False

In the Celeryd log:

[2012-11-01 11:15:23,442: INFO/MainProcess] Task celerytasks.tasks.SyncUsers[9e8f4da3-17d2-4944-9095-51de1afcaaf3] succeeded in 34.596668005s: <website.bullhorn.api.APIResult object at...

Anybody know what's happening here?

EDIT: Just noticed that when I call get() now I see:

....\lib\site-packages\djcelery\managers.py:183: TxIsolationWarning: Polling results with transaction isolation level repeatable-read within the same transaction may give outdated results. Be sure to commit the transaction for each poll iteration. "Polling results with transaction isolation level "

and it still waits forever.

4

1 回答 1

3

And so there was the answer. I'm using MySQL so I needed to set the transaction isolation level to READ-COMMITTED

http://dev.mysql.com/doc/refman/5.1/en/set-transaction.html

Also credit goes to http://www.no-ack.org/2010/07/mysql-transactions-and-django.html for pointing me in the right direction. (Blog appears to be closed to public access now)

于 2012-11-01T12:50:51.020 回答