mod_wsgi在压力下失败

Bug*_*ari 7 python linux mod-wsgi

我试着给我的服务器压力一点,发生了一些奇怪的事情.我正在使用mod_wsgi,插入了基本脚本:

import socket

def application(environ, start_response):
    status = '200 OK'
    output = 'Hello World!'
    response_headers = [('Content-type', 'text/plain'),
                    ('Content-Length', str(len(output)))]
    start_response(status, response_headers)
    return [output]
Run Code Online (Sandbox Code Playgroud)

我试图通过简单的"尽我所能"来强调它:

#!/bin/zsh

for i in {1..50}
do
wget http://$this_site/ &
done
Run Code Online (Sandbox Code Playgroud)

奇怪的事情发生了 - 在我的服务器上报告有关错误500的报告.

当我查看apache日志时,这就是我发现的

[Sat Mar 10 21:46:18 2012] [error] [client 95.49.81.25] mod_wsgi (pid=23632): Target WSGI script '/home/tricky/www/run.py' cannot be loaded as Python module.
[Sat Mar 10 21:46:18 2012] [error] [client 95.49.81.25] mod_wsgi (pid=23632): Exception occurred processing WSGI script '/home/tricky/www/run.py'.
[Sat Mar 10 21:46:18 2012] [error] [client 95.49.81.25] Traceback (most recent call last):
[Sat Mar 10 21:46:18 2012] [error] [client 95.49.81.25]   File "/home/tricky/www/run.py", line 1, in <module>
[Sat Mar 10 21:46:18 2012] [error] [client 95.49.81.25]     import web
[Sat Mar 10 21:46:18 2012] [error] [client 95.49.81.25]   File "/usr/local/lib/python2.7/site-packages/web.py-0.36-py2.7.egg/web/__init__.py", line 14, in <module>
[Sat Mar 10 21:46:18 2012] [error] [client 95.49.81.25]     import utils, db, net, wsgi, http, webapi, httpserver, debugerror
[Sat Mar 10 21:46:18 2012] [error] [client 95.49.81.25]   File "/usr/local/lib/python2.7/site-packages/web.py-0.36-py2.7.egg/web/wsgi.py", line 8, in <module>
[Sat Mar 10 21:46:18 2012] [error] [client 95.49.81.25]     import http
[Sat Mar 10 21:46:18 2012] [error] [client 95.49.81.25] ImportError: No module named http
Run Code Online (Sandbox Code Playgroud)

这怎么可能?为什么会这样?

Bug*_*ari 0

好吧,我找到了解决方案 - apache2 在弄乱其配置后出现了一些奇怪的竞争状态。service apache2 restart一切恢复正常后:)