相关疑难解决方法(0)

使用Bottle框架的Python粘贴破坏管道错误

我正在使用实现WSGI请求和响应的Bottle框架,并且由于单线程问题,我将服务器更改为PythonWSGIServer并使用Apache bench进行测试但结果包含错误中断管道,这与此问题类似如何防止errno 32中断管?.我已经尝试了答案但无济于事.

  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
Run Code Online (Sandbox Code Playgroud)

服务器代码如下所示,我不知道如何使用线程池改善连接?

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)
Run Code Online (Sandbox Code Playgroud)

python paste

5
推荐指数
1
解决办法
1854
查看次数

捕获瓶子服务器错误

我试图让我的瓶子服务器,以便当游戏中的一个人注销时,每个人都可以立即看到它.当我使用长轮询时,会向所有用户打开请求.

我遇到问题的一点是捕获当用户从长轮询中离开页面时抛出的异常,该轮询不能再连接到页面.错误消息在这里.

Traceback (most recent call last):
  File "/usr/lib/python2.7/dist-packages/gevent/pywsgi.py", line 438, in handle_one_response
    self.run_application()
  File "/usr/lib/python2.7/dist-packages/gevent/pywsgi.py", line 425, in run_application
    self.process_result()
  File "/usr/lib/python2.7/dist-packages/gevent/pywsgi.py", line 416, in process_result
    self.write(data)
  File "/usr/lib/python2.7/dist-packages/gevent/pywsgi.py", line 373, in write
    self.socket.sendall(msg)
  File "/usr/lib/python2.7/dist-packages/gevent/socket.py", line 509, in sendall
    data_sent += self.send(_get_memory(data, data_sent), flags)
  File "/usr/lib/python2.7/dist-packages/gevent/socket.py", line 483, in send
    return sock.send(data, flags)
error: [Errno 32] Broken pipe
<WSGIServer fileno=3 address=0.0.0.0:8080>: Failed to handle request:
  request = GET /refreshlobby/1 HTTP/1.1 from ('127.0.0.1', 53331)
  application = <bottle.Bottle object at …
Run Code Online (Sandbox Code Playgroud)

python long-polling bottle python-2.7

4
推荐指数
1
解决办法
1249
查看次数

标签 统计

python ×2

bottle ×1

long-polling ×1

paste ×1

python-2.7 ×1