我和redis一起设置了djcelery。 我可以在redis中看到日志
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"
但芹菜中没有记录
[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
-> 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
这是我的设置文件和任务
# Celery settings
djcelery.setup_loader()
BROKER_URL = 'redis://localhost:6379/2'
CELERY_RESULT_BACKEND = 'redis://localhost:6379/2'
INSTALLED_APP = (
...
'djcelery',
)
from celery import task
@task()
def add(x, y):
return x + y
当我执行任务时,其状态始终是' PENDING'。对此有何想法?