2010-07-27 66 views
2

WSGI應用mod_wsgi + apache沒有多線程,爲什麼?


# coding: utf-8 

import time 

def application(environ, start_response): 
    status = '200 OK' 
    output = str(time.time()) 
    time.sleep(5) 
    output += ' -> ' + str(time.time()) 

    response_headers = [('Content-type', 'text/html; charset=utf-8'), 
         ('Content-Length', str(len(output)))] 
    start_response(status, response_headers) 

    return [output] 

阿帕奇虛擬主機



    ServerName localhost 

    WSGIDaemonProcess main user=www-data group=www-data processes=1 threads=5 
    WSGIScriptAlias//var/www/main/main.wsgi 

    
     WSGIProcessGroup main 
     WSGIApplicationGroup %{GLOBAL} 
     Order deny,allow 
     Allow from all 
    

    ErrorLog /var/log/apache2/main_error_log 
    CustomLog /var/log/apache2/main_log common 

Сonnecting多個客戶端,它們被順序地處理,沒有多線程。爲什麼?

+0

apache包,具體是什麼? – 2010-07-27 07:33:18

+2

提供圍繞WSGIProcessGroup的配置缺失位。我假設它缺失,否則爲什麼它縮進。另外,你使用的是什麼Apache MPM,並且當你不應該擁有MPM設置時,讓你擺弄它。 – 2010-07-27 09:34:01

回答

1

雖然不完全是一個答案,就用多個標籤的單個瀏覽器進行測試時,我注意到有一個類似的設置串行行爲。 (我試過chrome7和ff4)

想知道如果是瀏覽器強制執行串行方式,我試着用兩個獨立的瀏覽器進行同樣的實驗,並且它肯定顯示服務器是多線程的。

我的設置是:
mod_wsgi的3.3-1
蟒蛇上的archlinux x86_64的
測試採用嵌入式模式mod_wsgi的運行3.1.2-2
阿帕奇2.2.17-1

希望它幫助。

相關問題