Async in django rest framework
You shouldn't be turning create
into an async function. You should have a loop within the create
that runs all your logic asynchronously but even that won't free up the worker process to serve other requests while your async tasks run. The best you can do here is offload the tasks to celery and then poll through another API to check for their status or result.
Django's a synchronous framework and it won't support what you're trying to do here. If you want to have long-polling with overlapping requests then I'd suggest looking into tornado