Drxxd Drxxd - 1 year ago 162
Python Question

Celery send_task doesn't send tasks

I have a server running Celery with RabbitMQ. But when I try to send tasks using send_task, it just returns with an AsyncResult object.

But the actual task is not running (even though the workers and the queues are empty)

c = Celery("tasks", broker="amqp://guest@")
c.send_task("tasks.printing.test_print", (100), queue="print_queue", routing_key="printing.test_print")

My celery configuration is:

Queue('default', routing_key='task.#'),
Queue('print_queue', routing_key='printing.#'),
'tasks.printing.test_print': {
'queue': 'print_queue',
'routing_key': 'printing.test_print',
BROKER_URL = 'amqp://'

I execute only one worker:

celery -A celerymain worker --loglevel=debug

This is it's initial log:

- ** ---------- [config]
- ** ---------- .> app: __main__:0x7eff96903b50
- ** ---------- .> transport: amqp://guest:**@localhost:5672//
- ** ---------- .> results: amqp://
- *** --- * --- .> concurrency: 4 (prefork)
-- ******* ----
--- ***** ----- [queues] -------------- .> default exchange=tasks(topic) key=task.#
.> print_queue exchange=tasks(topic) key=printing.#

[tasks] . test_print

This is the task:

class test_print(Task):

name = "test_print"

def run(self,a):
print a

The rabbitMQ queue 'print_queue' stays empty and there is nothing new in the rabbitMQ logs.

I have 4 GB free space so it's not a disk space problem.

What can be the problem here?

Answer Source

I solved the problem by removing the routing_key parameter from send_task.
I don't really know why this was a problem but at least it works

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download