Quantcast
Channel: Recent Questions - Stack Overflow
Viewing all articles
Browse latest Browse all 12111

Is Django (especially Django Rest Framework) really synchronous?

$
0
0

I know some concepts that Django (DRF) is synchronous and it has some workers, but I know little about this.

I tried to verify this and created this view at the address http://localhost:8000/my-view/:

def my_view(request):    # Simulate some time-consuming task    time.sleep(10)    return HttpResponse("Response after 10 seconds")

I proceeded to open 7 terminals and execute the same command on each of them within a range of 1-2 seconds (almost simultaneously):

curl http://localhost:8000/my-view/ -H 'Content-Type: application/json'

--> and the result was that in each terminal I received response in 10-12 seconds.

Here is the question, if Django is synchronous so why it did not take 70 seconds to execute these requests one by one?

The only explanation I can think of is that it uses multithreading.


Viewing all articles
Browse latest Browse all 12111

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>