How can one return offloaded process response from celery?
Typically this is handled by making the HTTP interaction asynchronous as well.
Instead of returning the PDF, you'd return a future link that the PDF will be available on or a processing status page, and the client can poll on that link to retrieve the PDF. Typically, this is done by returning HTTP 202 Accepted response.
Other alternative that may be suitable in different circumstances is to return the response in a WebSocket push message. This may be suitable if your already have a WebSocket connection in the app or if you need lower latency than can be provided by polling. If the processing takes very long time (e.g hours), it may be appropriate to ask the user their email address (or take the email address from the user's profile) and send the user an email when they can retrieve the result.
I work on web application that generates pdf, it returns generated pdf file. Previously I handled the pdf generation in the main process. My superior told me, that will potentially cause the app to stall, as django is synchronous.
So he suggest offload the process to celery, I tried it and have the idea about how to process it using celery. But I can't figure out the how to return the response to the client.
I can return response that it's being processed, but what about the pdf file? return the possible url too? and send request every now and then?