【发布时间】:2013-07-20 09:06:41
【问题描述】:
我正在使用 apache 2.2,我曾尝试运行 2 个线程(并行),但我似乎无法让两个线程按顺序运行。
如何强制它同时(并行)运行??
test.wsgi::
import time
def application(environ, start_response):
status = '200 OK'
output = str(time.time())
time.sleep(5)
output += '<br/>' + str(time.time())
response_headers = [('Content-type', 'text/html; charset=utf-8'),
('Content-Length', str(len(output)))]
start_response(status, response_headers)
return [output]
我在 httpd.conf 的末尾插入了以下内容:
Include conf/extra/httpd-mpm.conf
<IfModule mpm_winnt_module>
ThreadsPerChild 253
MaxRequestsPerChild 0
</IfModule>
<VirtualHost *>
ServerName localhost
WSGIScriptAlias / C:\test\test.wsgi
<Directory C:\test>
Order deny,allow
Allow from all
</Directory>
</VirtualHost>
我得到了这样的作品,但不是并行的,
第一个线程: 1374420108.56 1374420113.56
第二个线程: 1374420113.57 1374420118.57
谢谢
【问题讨论】:
标签: python windows multithreading apache flask