I want to trigger a background task (just trigger, not require to wait till finish), when user does the POST request.
I know, I can do it with celery
. But don't want to add the task in queue, as it has to be triggered immediately. This task can be long running, so after triggering I don't want to hold the POST call and just send response as request received.
There might be a way using thread, but can I do it with asyncio
or any other lib in python.
Python 3.5 and Django 2.2 with DRF
Asked
Active
Viewed 606 times
0

pab789
- 123
- 1
- 10
-
Check this answer https://stackoverflow.com/a/26270790/5375584 – Vipin Mohan Nov 21 '19 at 08:07
-
So for my case, I can just go with Threading, No need to use asyncio right? – pab789 Nov 21 '19 at 09:05
-
Yes. There are quite a few ways you can tackle it, it ultimately depends on what you need to do. Therading, multiprocess , asyncio etc some of the easiest ways. you can also pawn of the heavy work to celeary, huey etc – Vipin Mohan Nov 21 '19 at 09:10