I write a bot for Vkontakte on Django(2.2.4), with the vk_api library
Some of the functions are quite long (performed in 5-7 seconds). But Vkontakte requires the server to respond no longer than 3 seconds. If the response is delayed, the request is sent again, and the bot starts sending the same message many times after a while. (I Use The Callback Api)
I will describe my problem briefly
my function runs for more than 6 seconds
the 200OK response must be sent in less than 3 seconds
Is it possible to solve this problem without major changes in the code?
# views.py
@csrf_exempt
def MainBotView(request):
# i need something like return HttpResponse('ok') here
... my slow code ...
return HttpResponse('ok') # but I don't need it at the end
(I use pythonanywhere and Celery perhaps does not work there)
Should I use threading? How?