0

I've set up the djcelery along with redis. I can see the logs in redis

redis-cli MONITOR

1454060863.881506 [0 [::1]:59091] "INFO"
1454060863.883295 [0 [::1]:59093] "MULTI"
1454060863.883314 [0 [::1]:59093] "LLEN" "celery"
1454060863.883319 [0 [::1]:59093] "LLEN" "celery\x06\x163"
1454060863.883323 [0 [::1]:59093] "LLEN" "celery\x06\x166"
1454060863.883326 [0 [::1]:59093] "LLEN" "celery\x06\x169"
1454060863.883331 [0 [::1]:59093] "EXEC"
1454060863.883704 [0 [::1]:59093] "SADD" "_kombu.binding.celery" "celery\x06\x16\x06\x16celery"
1454060863.884054 [0 [::1]:59093] "SMEMBERS" "_kombu.binding.celery"
1454060863.884421 [0 [::1]:59093] "LPUSH" "celery" "{\"body\": \"gAJ9cQEoVQdleHBpcmVzcQJOVQN1dGNxA4hVBGFyZ3NxBEsESwSGcQVVBWNob3JkcQZOVQljYWxsYmFja3NxB05VCGVycmJhY2tzcQhOVQd0YXNrc2V0cQlOVQJpZHEKVSQwZGQwZmJmZC0zYTQ0LTQxMDMtOTNiOC01NmI4ZmFjNjE0MDJxC1UHcmV0cmllc3EMSwBVBHRhc2txDVUPdXRpbHMudGFza3MuYWRkcQ5VCXRpbWVsaW1pdHEPTk6GVQNldGFxEE5VBmt3YXJnc3ERfXESdS4=\", \"headers\": {}, \"content-type\": \"application/x-python-serialize\", \"properties\": {\"body_encoding\": \"base64\", \"correlation_id\": \"0dd0fbfd-3a44-4103-93b8-56b8fac61402\", \"reply_to\": \"b9f02cee-e562-3e86-90aa-683d205d060c\", \"delivery_info\": {\"priority\": 0, \"routing_key\": \"celery\", \"exchange\": \"celery\"}, \"delivery_mode\": 2, \"delivery_tag\": \"b44aafc9-e6aa-4cd8-8a70-201d895cbd7f\"}, \"content-encoding\": \"binary\"}"
1454060872.513147 [0 [::1]:59204] "GET" "celery-task-meta-0dd0fbfd-3a44-4103-93b8-56b8fac61402"

But there's no logs in celery

python manage.py celeryd -l debug

[2016-01-29 10:14:51,073: DEBUG/MainProcess] | Worker: Preparing bootsteps.
[2016-01-29 10:14:51,075: DEBUG/MainProcess] | Worker: Building graph...
[2016-01-29 10:14:51,075: DEBUG/MainProcess] | Worker: New boot order: {Timer, Hub, Queues (intra), Pool, Autoscaler, StateDB, Autoreloader, Beat, Consumer}
[2016-01-29 10:14:51,084: DEBUG/MainProcess] | Consumer: Preparing bootsteps.
[2016-01-29 10:14:51,085: DEBUG/MainProcess] | Consumer: Building graph...
[2016-01-29 10:14:51,097: DEBUG/MainProcess] | Consumer: New boot order: {Connection, Events, Heart, Agent, Mingle, Gossip, Tasks, Control, event loop}
-------------- celery@Kumars-MacBook-Pro-2.local v3.1.20 (Cipater)
---- **** -----
--- * ***  * -- Darwin-14.5.0-x86_64-i386-64bit
-- * - **** ---
- ** ---------- [config]
- ** ---------- .> app:         default:0x109177ed0 (djcelery.loaders.DjangoLoader)
- ** ---------- .> transport:   redis://localhost:6379/2
- ** ---------- .> results:     redis://localhost:6379/2
- *** --- * --- .> concurrency: 4 (prefork)
-- ******* ----
--- ***** ----- [queues]
-------------- .> celery           exchange=celery(direct) key=celery
[tasks]

. celery.backend_cleanup
. celery.chain
. celery.chord
. celery.chord_unlock
. celery.chunks
. celery.group
. celery.map
. celery.starmap
. utils.tasks.add

[2016-01-29 10:14:51,113: DEBUG/MainProcess] | Worker: Starting Pool

python manage.py celerycam

-> evcam: Taking snapshots with djcelery.snapshot.Camera (every 1.0 secs.)
[2016-01-29 09:58:10,377: INFO/MainProcess] Connected to redis://localhost:6379/2

This is my settings file and the task

settings.py

# Celery settings
djcelery.setup_loader()

BROKER_URL = 'redis://localhost:6379/2'
CELERY_RESULT_BACKEND = 'redis://localhost:6379/2'
INSTALLED_APP = (
    ...
    'djcelery',
)

tasks.py

from celery import task

@task()
def add(x, y):
    return x + y

When I run the task, its state is always 'PENDING'. Any idea on this?

Kumar Nitin
  • 1,845
  • 2
  • 16
  • 21
  • What versions are you using (Django specially)? Why are you using `djcelery`? I recall something about being a deprecated package, and I have a setup of Django1.9 + Celery without that specific package. (I am gonna check just in case). – MariusSiuram Jan 29 '16 at 10:47
  • Django: 1.7.7 django-celery: 3.1.16 Redis: 3.0.2 – Kumar Nitin Jan 29 '16 at 10:54
  • Celery version? If it is equal or greater than 3.1, you should be able (and recommended) to use [this way](http://docs.celeryproject.org/en/latest/django/first-steps-with-django.html) instead of the old `django-celery` package. – MariusSiuram Jan 29 '16 at 10:56
  • Before this I tried celery too (3.1.20) yet I was getting the same issue. – Kumar Nitin Jan 29 '16 at 10:58
  • check that my link recommends a different way to set up everything. No `djcelery` installed app, and a different way to set up celery worker. I have experience with Redis + Django + Celery, but zero experience with `django-celery`. – MariusSiuram Jan 29 '16 at 11:00
  • Let me try that then, – Kumar Nitin Jan 29 '16 at 11:21

0 Answers0