Reputation: 138
I have a Django app where I have created a custom middleware.
It works as follows:
This is my question: Because my app has to wait for the API request to return before it can process the request, does it still make sense to use a task queue such as celery? Wouldn't it still have to block the thread while I waiting for the response?
Upvotes: 5
Views: 734
Reputation: 1208
this is not mandatory in your described case, unless you need to handle thousands of this requests type of requests which need to be queued.
Upvotes: 0
Reputation: 599856
No, using Celery here wouldn't make any sense at all. That's for tasks that can be purely out-of-process. A good example is sending a confirmation email; the response sent to the browser doesn't have to wait for the email to be sent, because it doesn't depend on it in any way.
In your case, the response explicitly does depend on the value from the API. There would be nothing to be gained from using Celery, and it would make the whole process much more complex than it needs to be.
Upvotes: 8