0

I've just started work on a project that uses Django & Celery. I'm quite new to both. One of the endpoints has code that looks like this:

task_do_something.delay()
return Response(
            {"success": True},
            status=status.HTTP_200_OK
        )

task_do_something is a task that takes a while to complete. (It does not call any other Celery tasks.) Will the main process execute the return statement immediately after Celery queues the task? Or will it wait for the task to be complete before moving on to the next line?

Reading through the documentation, I'm inclined to think that the answer would be the first option (execute next statement after the task is queued), because Celery tasks are asynchronous. But I'd like to double-check.

2
  • What do you mean by "main process"? Do you mean the Django app? Commented Jan 23, 2024 at 1:40
  • And yes, the task is queued up then execution continues in your django request handler. Commented Jan 23, 2024 at 1:42

0

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.