开发者社区> 问答> 正文

Python Bottle框架变得无响应

我在使用python的Bottle框架(http://bottlepy.org/docs/dev/index.html)托管网页时遇到问题。在某些时间段内它似乎可以正常工作,但有时会出现以下错误,并且无法显示该网页。脚本不会崩溃,但是网页没有响应。

有什么建议么?

Traceback (most recent call last):
  File "/usr/lib/python2.7/SocketServer.py", line 295, in _handle_request_noblock
    self.process_request(request, client_address)
  File "/usr/lib/python2.7/SocketServer.py", line 321, in process_request
    self.finish_request(request, client_address)
  File "/usr/lib/python2.7/SocketServer.py", line 334, in finish_request
    self.RequestHandlerClass(request, client_address, self)
  File "/usr/lib/python2.7/SocketServer.py", line 651, in __init__
    self.finish()
  File "/usr/lib/python2.7/SocketServer.py", line 710, in finish
    self.wfile.close()
  File "/usr/lib/python2.7/socket.py", line 279, in close
    self.flush()
  File "/usr/lib/python2.7/socket.py", line 303, in flush
    self._sock.sendall(view[write_offset:write_offset+buffer_size])
error: [Errno 32] Broken pipe

我也看到以下错误。但是我猜测如果请求到不存在的网页/对象的请求会发生这些情况-

Traceback (most recent call last):
  File "/usr/lib/python2.7/SocketServer.py", line 295, in _handle_request_noblock
    self.process_request(request, client_address)
  File "/usr/lib/python2.7/SocketServer.py", line 321, in process_request
    self.finish_request(request, client_address)
  File "/usr/lib/python2.7/SocketServer.py", line 334, in finish_request
    self.RequestHandlerClass(request, client_address, self)
  File "/usr/lib/python2.7/SocketServer.py", line 649, in __init__
    self.handle()
  File "/usr/lib/python2.7/wsgiref/simple_server.py", line 116, in handle
    self.raw_requestline = self.rfile.readline()
  File "/usr/lib/python2.7/socket.py", line 447, in readline
    data = self._sock.recv(self._rbufsize)
error: [Errno 104] Connection reset by peer

展开
收起
祖安文状元 2020-02-23 16:36:16 5674 0
1 条回答
写回答
取消 提交回答
  • 这个问题似乎类似于如何防止errno 32损坏管道?

    您收到SIGPIPE,这可能是由于尝试写入已关闭的套接字。您可以尝试使用以下方式处理异常:

    except socket.error, e:
            if isinstance(e.args, tuple):
                print "Errno: %d" % e[0]
                if e[0] == errno.EPIPE:
    
    
               # Caught a peer disconnection
               print "Remote host disconnected"
    
    2020-02-23 16:36:25
    赞同 展开评论 打赏
问答分类:
问答地址:
问答排行榜
最热
最新

相关电子书

更多
From Python Scikit-Learn to Sc 立即下载
Data Pre-Processing in Python: 立即下载
双剑合璧-Python和大数据计算平台的结合 立即下载