处理ConnectionRestror& breakerpipeerror python http服务器
Python的新手在框架之外。需要一个简单的服务器来永远运行和加载一些PDF文件。
使用http.server测试在localhost
上运行远程服务器
PORT = 8000
Handler = http.server.SimpleHTTPRequestHandler
with socketserver.TCPServer(("", PORT), Handler) as httpd:
try:
httpd.serve_forever()
except SocketError as e:
if e.errno != errno.ECONNRESET:
raise
pass # Don't know what to do here.
。 在远程,服务器随机停止。 经常
检查日志后,我会收到2个错误时,当客户端加载时关闭浏览器时,
self._sock.sendall(b)
BrokenPipeError: [Errno 32] Broken pipe
发生错误,不知道是什么触发了这一点:
ConnectionResetError: [Errno 104] Connection reset by peer
如何处理这些?我需要添加等待时间或睡眠时间以避免。寻找Anyhelp。
New to python serves outside of a framework. Need a simple server to run and load few pdf files forever.
Running a server in remote using http.server
PORT = 8000
Handler = http.server.SimpleHTTPRequestHandler
with socketserver.TCPServer(("", PORT), Handler) as httpd:
try:
httpd.serve_forever()
except SocketError as e:
if e.errno != errno.ECONNRESET:
raise
pass # Don't know what to do here.
Testing at localhost
is working fine.
At remote, the server stops randomly. Upon checking logs I receive 2 errors frequently
Happens when client closes browser when a file is being loaded
self._sock.sendall(b)
BrokenPipeError: [Errno 32] Broken pipe
No idea what triggers this:
ConnectionResetError: [Errno 104] Connection reset by peer
How to handle these ? Do I need to add wait time or sleep time to avoid. Looking for anyhelp.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论