I am trying to run django server on aws ec2 instance (ubuntu) using screen command.
screen -L python3 manage.py runserver 0.0.0.0:8000
My script works in simple common way that it detects a POST request, processes and responds via HttpResponse.
My code looks somewhat like this in views.py.
def myResponse(arg):
"""
processing here
"""
#this function gets executed
#code below does not get executed, it gets cut off when, new request comes
HttpResponse("responseString")
def index(request):
if (request.method == "POST"):
"""
process here
"""
#this function gets triggered, whenever post request is detected
myResponse(arg)
HttpResponse("anotheresponseString")
When one user is interacting, and suddenly new user iteracts and new post request is detected, older flow get cut off. No error is thrown.
How do I handle multiple users ?
Use Gunicorn or Celery to run django server and handle your requests.
Gunicorn https://docs.djangoproject.com/en/2.2/howto/deployment/wsgi/gunicorn/
Celery https://docs.celeryproject.org/en/latest/django/first-steps-with-django.html