Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Does Django run in single thread by default?

Tags:

django

By reading the code, I found it seems that Django run in single thread by default.

However, when I use sleep(15) in my view function and open two web to request my function. They return the response almost at the same time!

so, I do not know why does it happened……

my Django version is 1.9

like image 201
yunji Avatar asked Sep 09 '16 10:09

yunji


1 Answers

Django itself does not determine whether it runs in one or more threads. This is the job of the server running Django.

The development server used to be single-threaded, but in recent versions it has been made multithreaded. Other servers such as Apache/mod_wsgi, gunicorn, or uwsgi, have their own defaults and can be configured in a number of ways; often they use multiple processes rather than threads.

like image 60
Daniel Roseman Avatar answered Sep 25 '22 00:09

Daniel Roseman