0

There is a view in the Django, for the submit button I say it: printSO

Now, the request is comming to view from two different browsers from the same machine, then how django is handling this?

Question:

Does it use any threading concept to invoke two different executions in parallel?

Considering the below scenario: pseudo code:

def results(request, emp_id):
    # if  emp_id exists in the database, then delete it.
    # send response with message "deleted"

Do we need to have any synchronization mechanism in the above code?

Flimzy
  • 68,325
  • 15
  • 126
  • 165
Whoami
  • 13,254
  • 17
  • 81
  • 133
  • They're two different clients.. The development server is single threaded and hence, not suited for this. When you use a different server (ie. Apache), several instances of the python interpreter are run (I'm absolutely not sure about the later, sorry) – Alvaro Oct 04 '13 at 15:43
  • possible duplicate of [Can Django do multi-thread works?](http://stackoverflow.com/questions/17601698/can-django-do-multi-thread-works) – Hedde van der Heide Oct 04 '13 at 15:45

1 Answers1

0

The Django development server is single threaded and not suited for processing more than a request at the same time (I believe this is due to the GIL lock). However, when combined with a different server , such as Apache, the later handles multithreading (in C). Here is some info (modwsgi) :

Modwsgi

To your final question: no, you don't need to sync anything in most cases

Since Django 1.4 the development server has been multi-threaded See here

though it is still not a production level webserver

Community
  • 1
  • 1
Alvaro
  • 11,321
  • 8
  • 39
  • 55
  • 1
    Since Django 1.4 the development server has been multi-threaded https://docs.djangoproject.com/en/1.4/releases/1.4/#development-server-multithreading though it is still not a production level webserver. – Mark Lavin Oct 04 '13 at 20:36