Python使用瓶子粘贴框架时发生断管错误
我使用瓶子框架实现WSGI请求和响应,由于单线程问题,我将服务器更改为PythonWSGIServer,并使用Apache bench进行测试,但结果是错误管道破裂,这与此问题类似。 我试过这个答案,但没有用Python使用瓶子粘贴框架时发生断管错误,python,paste,Python,Paste,我使用瓶子框架实现WSGI请求和响应,由于单线程问题,我将服务器更改为PythonWSGIServer,并使用Apache bench进行测试,但结果是错误管道破裂,这与此问题类似。 我试过这个答案,但没有用 Traceback (most recent call last): File "/Library/Python/2.7/site-packages/paste/httpserver.py", line 1068, in process_request_in_thread
Traceback (most recent call last):
File "/Library/Python/2.7/site-packages/paste/httpserver.py", line 1068, in process_request_in_thread
self.finish_request(request, client_address)
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/SocketServer.py", line 323, in finish_request
self.RequestHandlerClass(request, client_address, self)
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/SocketServer.py", line 641, in __init__
self.finish()
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/SocketServer.py", line 694, in finish
self.wfile.flush()
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/socket.py", line 303, in flush
self._sock.sendall(view[write_offset:write_offset+buffer_size])
error: [Errno 32] Broken pipe
服务器代码如下所示,我不知道如何使用线程池改进连接
from paste import httpserver
@route('/')
def index():
connection = pymongo.MongoClient(connectionString)
db = connection.test
collection = db.test
return str(collection.find_one())
application = default_app()
httpserver.serve(application, host='127.0.0.1', port=8082)
这是因为WSGIServer是一个同步服务器,不适用于同时发送请求的高并发用户。为了绕过这些回退,可以使用很多第三方框架。其中最受欢迎的是格文绿条图书馆、龙卷风和奇瑞比。它们都基于事件驱动和异步方法,使它们能够处理多个并发用户