簡體   English   中英

mod_wsgi + apache不是多線程的,為什么?

[英]mod_wsgi + apache not multithreaded, why?

WSGI應用程序


# 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

連接多個客戶端,它們將被順序處理,沒有多線程。 為什么?

這將在mod_wsgi郵件列表中處理。 看到:

http://groups.google.com/group/modwsgi/browse_frm/thread/b8aaab6bfc4cca6d

雖然不是完全正確的答案,但我注意到在具有多個標簽的單個瀏覽器上進行測試時,串行行為具有類似的設置。 (我嘗試了chrome7和ff4)

我想知道是否是由瀏覽器來實現串行性的,所以我嘗試使用兩個單獨的瀏覽器進行相同的實驗,它肯定表明服務器在運行多線程。

我的設置是:
mod_wsgi 3.3-1
python 3.1.2-2
阿帕奇2.2.17-1
在archlinux x86_64上
測試是在嵌入式模式下使用mod_wsgi運行的。

希望能幫助到你。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM