Django, sleep () pauses all processes, but only if there is no GET parameter?

Using Django (hosted by Webfaction), I have the following code

import time
def my_function(request):
    time.sleep(10)
    return HttpResponse("Done")

This is done through Django when I go to my url, www.mysite.com

I entered the URL twice, right after each other. As I see it, both of them should end in 10 seconds. However, the second call waits for the first and ends after 20 seconds.

If, however, I enter some dummy GET parameter, www.mysite.com?dummy=1 and www.mysite.com?dummy=2, then they both finish in 10 seconds. Thus, both of them can work simultaneously.

As if the sphere of sleep () is somehow global? Perhaps the input of the parameter leads to the fact that they start as different processes, and not the same ones ???

It is hosted by Webfaction. httpd.conf has:

KeepAlive Off
Listen 30961
MaxSpareThreads 3
MinSpareThreads 1
ServerLimit 1
SetEnvIf X-Forwarded-SSL on HTTPS=1
ThreadsPerChild 5

sleep() , . , ?

: Webfaction Apache.

+5
3

, . Webfaction, , WSGI Django. , , , Apache , (, Django). / , .

:

  • GET A. Apache ( )
  • 10
  • A. Apache , , A. , , , , , , / /, .
  • 20- , , 2 10 .

99% , .

, ( GET), Apache , ( "" (Apache ). , 10 , 10 .


, , - . , , HTTP- , . , , 10 - , . , , . , !
+8

, Django- run(), . , .

+3

It may just be that your browser is executing the sequence of the second request, which should only be executed after the first is completed. If you open your URLs in the same browser, try using two different ones (for example, Firefox and Chrome) or try to execute requests from the command line with wgetor curl.

+1
source

All Articles