Alejandro Veintimilla
Alejandro Veintimilla

Reputation: 11543

Django. Celery delay() not printing to terminal

I have a simple Celery task in Django:

from celery.decorators import task

@task
def celery_test(x, y):
    print x + y
    return None

I call it in a view:

...
def get_queryset(self, *args, **kwargs):
        celery_test.delay("uno ", "dos")
        ...

So, when I call the function with delay it doesn't print anything to the terminal, why?, ... when I call it whithout delay it prints things correctly. I'm using RabbitMQ server and it is running fine.

Upvotes: 0

Views: 1445

Answers (1)

somecallitblues
somecallitblues

Reputation: 733

Check your log file for celery. It'll probably print it there.

EDIT

When you use .delay() the task is decoupled from the terminal and all you get printed is something like this:

AsyncResult: 3df665f1-547d-49bb-937b-8190a63bfeb7.

What happens is that you've passed the code to the broker and the broker can't print back to terminal. But if you have a print statements in your code they'll be printed into your celery log.

Upvotes: 2

Related Questions