Drxxd
Drxxd

Reputation: 1929

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://[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?

Upvotes: 6

Views: 3523

Answers (2)

user7139980
user7139980

Reputation: 1

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

    name = "test_print"

    def run(self,a):
        log.info("running")
        print a

Upvotes: -2

Drxxd
Drxxd

Reputation: 1929

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

Upvotes: 4

Related Questions