6

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://[email protected]//")
c.send_task("tasks.printing.test_print", (100), queue="print_queue", routing_key="printing.test_print")

My celery configuration is:

CELERY_QUEUES = (
    Queue('default',    routing_key='task.#'),
    Queue('print_queue', routing_key='printing.#'),
)
CELERY_DEFAULT_EXCHANGE = 'tasks'
CELERY_ROUTES = {
        '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):
        log.info("running")
        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?

2 Answers 2

4

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

-2
@app.task(name="test_print")
class test_print(Task):

    name = "test_print"

    def run(self,a):
        log.info("running")
        print a
1
  • 3
    What are you trying to say?
    – Drxxd
    Nov 10, 2016 at 13:44

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.