3

my friends all the time talking about doing time-consuming task with celery .since i haven't computer science i can't get exactly about time of execution of celery task . in celery document talking about daemon when calling .delay() but i can't found what is daemon and finally when exactly celery task will be execute if we call it by .delay() ? :)

for example if i have below code when my_task will be execute? function.py:

def test():
    my_task.delay()
    while second<10:
       second += 1 # assume this part take a second

1-exactly when test() function finished (about 10 second after test() called)

2-in the middle of while loop

3- after finished test() and when requests wasn't too many and server have time and resources to do task!! (maybe celery is intelligent and know the best time for execute task)

4- whenever want :)

5- correct way that i don't pointed to . :)

if it's depending to configuration i must tell i used default configuration from celery documentation.thank you.

1 Answer 1

4

Imagine that you do not have this task alone but several ones. You put all these tasks on a queue if you invoke it with my_task.delay(). Now there are several workers which just picks the first open task and will execute them.

So the right answer would be "Whenever the responsible worker is free". This could be immediately just before you go into your while second<10:-loop but could also take several seconds or minutes if the worker is currently busy.

Sign up to request clarification or add additional context in comments.

1 Comment

It may be obvious, but we should note that we need at least one worker available to make sure the task is executed at all...

Your Answer

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

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.