You're delaying the function and calling it asynchronously. Therefore, inevitably, your code doesn't wait until it has the result. As that is sort of the point.
So Celery will start running celery_task
in the background, and you will have to return something to the client without knowing what the result is going to be. Maybe if the task is done it can save the data to a database or so, and the next time the user goes to the page you can show the finished data from the database. Or anything else.
What you get back from .delay
is a sort of handle to the background task. You could call .get()
on it (if I recall correctly) and that will hang until it gets the return value, but then you're back to calling the function synchronously.