Reputation: 241
I am using Django, celery, and DjangoRestFramework for APIs. I have an API that takes around 1 minute to show data in JSON format. The problem is Heroku ( server) shows application error if a function takes more than 30 seconds. Hence I want to put my API into celery tasks. Please suggest the way to do so.
Upvotes: 2
Views: 1862
Reputation: 4635
Maybe you can do something like this :
GET/POST/etc come to a particular end-point
View attached to url is activated
Here you can start/initialize the celery task and return the job id (investigation needed on this id part, I guess celery task return some EagerResult or something syncronously/ you can implement custom job id feature)
User gets the job id for there particular request
5 User can make another request after some delay using that id
This is just an overview of my initial thoughts. Much thoughts, refinement required.
Lemme know your thoughts.
Upvotes: 3