2017-05-10 61 views
1

我寫了一個非常簡單的燒瓶服務器。此服務器迴應GET並回饋我的home.html。 我訪問的網站上127.0.0.1:5000當被請求太頻繁時,燒瓶給出「錯誤32破管」

一切都很好,直到現在。但是,如果我在我的計算機上一直按下「新鮮」(Command + R在我的電腦上)很多次,並且速度儘可能快,那麼我的瓶子就會給出這個錯誤並且發生故障。

Exception in thread Thread-1: Traceback (most recent call last): File "/usr/local/Cellar/python/2.7.11/Frameworks/Python.framework/Versions/2.7/lib/python2.7/threading.py", line 801, in bootstrap_inner self.run() File "/usr/local/Cellar/python/2.7.11/Frameworks/Python.framework/Versions/2.7/lib/python2.7/threading.py", line 754, in run self.__target(*self.__args, **self.__kwargs) File "/usr/local/lib/python2.7/site-packages/werkzeug/serving.py", line 659, in inner srv.serve_forever() File "/usr/local/lib/python2.7/site-packages/werkzeug/serving.py", line 499, in serve_forever HTTPServer.serve_forever(self) File "/usr/local/Cellar/python/2.7.11/Frameworks/Python.framework/Versions/2.7/lib/python2.7/SocketServer.py", line 238, in serve_forever self._handle_request_noblock() File "/usr/local/Cellar/python/2.7.11/Frameworks/Python.framework/Versions/2.7/lib/python2.7/SocketServer.py", line 297, in _handle_request_noblock self.handle_error(request, client_address) File "/usr/local/Cellar/python/2.7.11/Frameworks/Python.framework/Versions/2.7/lib/python2.7/SocketServer.py", line 295, in _handle_request_noblock self.process_request(request, client_address) File "/usr/local/Cellar/python/2.7.11/Frameworks/Python.framework/Versions/2.7/lib/python2.7/SocketServer.py", line 321, in process_request self.finish_request(request, client_address) File "/usr/local/Cellar/python/2.7.11/Frameworks/Python.framework/Versions/2.7/lib/python2.7/SocketServer.py", line 334, in finish_request self.RequestHandlerClass(request, client_address, self) File "/usr/local/Cellar/python/2.7.11/Frameworks/Python.framework/Versions/2.7/lib/python2.7/SocketServer.py", line 655, in __init self.handle() File "/usr/local/lib/python2.7/site-packages/werkzeug/serving.py", line 216, in handle rv = BaseHTTPRequestHandler.handle(self) File "/usr/local/Cellar/python/2.7.11/Frameworks/Python.framework/Versions/2.7/lib/python2.7/BaseHTTPServer.py", line 340, in handle self.handle_one_request() File "/usr/local/lib/python2.7/site-packages/werkzeug/serving.py", line 251, in handle_one_request return self.run_wsgi() File "/usr/local/lib/python2.7/site-packages/werkzeug/serving.py", line 193, in run_wsgi execute(self.server.app) File "/usr/local/lib/python2.7/site-packages/werkzeug/serving.py", line 184, in execute write(data) File "/usr/local/lib/python2.7/site-packages/werkzeug/serving.py", line 152, in write self.send_header(key, value) File "/usr/local/Cellar/python/2.7.11/Frameworks/Python.framework/Versions/2.7/lib/python2.7/BaseHTTPServer.py", line 401, in send_header self.wfile.write("%s: %s\r\n" % (keyword, value)) IOError: [Errno 32] Broken pipe

我相信這是發生了什麼:當我的服務器試圖傳輸HTML到我的瀏覽器時,我按下刷新並打破管道。所以我的服務器感到困惑,然後給出錯誤。

如何解決這個問題?或者這個網站是不可用的,因爲任何人經常問我的網頁可以打破我的網頁。

謝謝!

回答

0

出現此錯誤是因爲您的服務器超載!停止並啓動它!

2

你可以嘗試使用app.run(threaded=True)this SO建議的答案。

0

我看到這個錯誤太Ubuntu的泊塢容器上Kubernetes在Ubuntu VM:

Error on request: 
Traceback (most recent call last): 
    File "/usr/local/lib/python2.7/dist-packages/werkzeug/serving.py", line 270, in run_wsgi 
    execute(self.server.app) 
    File "/usr/local/lib/python2.7/dist-packages/werkzeug/serving.py", line 261, in execute 
    write(data) 
    File "/usr/local/lib/python2.7/dist-packages/werkzeug/serving.py", line 227, in write 
    self.send_header(key, value) 
    File "/usr/lib/python2.7/BaseHTTPServer.py", line 412, in send_header 
    self.wfile.write("%s: %s\r\n" % (keyword, value)) 
IOError: [Errno 32] Broken pipe 

我創建了一個全新的Ubuntu xenial VM跑在Kubernetes Ubuntu的碼頭工人容器相同的代碼,而這個錯誤是不是看到和Python Flask按預期工作。我認爲這是我的主機(Ubuntu VM)的問題。