Skip to main content
 首页 » 编程设计

python之mod_wsgi + apache 不是多线程的,为什么

2024年08月12日36开发

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] 

Apache 虚拟主机

 
 
    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