Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Celery is not working on my Heroku

What on earth am I doing wrong?

I have recently found an awesome django template called django-skel. I started a project with it because it made it very easy to use heroku with django. It was all going great until I tried to get celery working. No matter what I tried I couldn't get my tasks to run. So I started a new bare bones app just to see if I could get it working without any of my other craziness preventing things.

This is my bare-bones app. I have this up and running on heroku. Django admin is working, I have my databases sync'd up and migrated. I am using CloudAMQP Little Lemur for my RabbitMQ. I see the requests queued up in the RabbitMQ interface, nothing happens. How I queue up the tasks is manually run in the shell:

from herokutest.apps.otgcelery.tasks import add
result = add.delay(2,2)

I make sure that I have all 3 dynos running, and still nothing.

Also I have it working locally.

I am sure there are tons of questions, and I'm willing to give them. Just please ask.

like image 440
Chris Avatar asked Nov 03 '22 23:11

Chris


1 Answers

Thank you for everyones help. There were a couple things that I ended up doing wrong. First thing was that I was importing the task incorrectly. All I had to do was:

from apps.otgcelery.tasks import add
result = add.delay(2,2)

Celery is very picky with how you import your tasks. The second issue is that CloudAMQP Free addon does not work out of the box with django-skel. They limit your number of connections to three, and how each thread kicks on it uses those connections up incredibly fast and your tasks just start not connecting. So I fixed this in a couple different ways. I tried another BigWigs RabbitMQ, and it worked great. However, because they were still in Beta I decided to try out Redis. That also worked great, and my tasks are firing off as fast as I can call them.

Once again thank you everyone for your help.

like image 136
Chris Avatar answered Nov 09 '22 17:11

Chris