【发布时间】:2019-04-29 13:52:57
【问题描述】:
我有一个我一直在开发的 webApp,我注意到每隔一段时间我会看到“线程 CP 服务器线程中的异常-*”错误,其中 * = 随机线程数。此错误偶尔会发生最终会锁定网络服务器,阻止它响应请求。
我能够使用 CherryPy 支持 SSL 的默认“hello World”webPy 应用程序重现相同的问题。
import web
from web.wsgiserver import CherryPyWSGIServer
# GLOBALS
CherryPyWSGIServer.ssl_certificate = "/.ssl/fpi.crt"
CherryPyWSGIServer.ssl_private_key = "/.ssl/server.key"
urls = (
'/(.*)', 'Hello',
)
app = web.application(urls, globals())
class Hello:
def GET(self, name):
return 'Hello World'
if __name__ == "__main__":
app.run()
错误是:
73.220.196.76:63982 - - [27/Nov/2018 06:56:50] "HTTP/1.1 GET /" - 200 OK
73.220.196.76:63982 - - [27/Nov/2018 06:56:50] "HTTP/1.1 GET /favicon.ico" - 200 OK
Exception in thread CP Server Thread-9:
Traceback (most recent call last):
File "/usr/lib/python2.7/threading.py", line 801, in __bootstrap_inner
self.run()
File "/home/brian_barnes/.local/lib/python2.7/site-packages/web/wsgiserver/__init__.py", line 1375, in run
conn.communicate()
File "/home/brian_barnes/.local/lib/python2.7/site-packages/web/wsgiserver/__init__.py", line 1269, in communicate
format_exc())
File "/home/brian_barnes/.local/lib/python2.7/site-packages/web/wsgiserver/__init__.py", line 811, in simple_response
self.conn.wfile.sendall("".join(buf))
File "/home/brian_barnes/.local/lib/python2.7/site-packages/web/wsgiserver/ssl_pyopenssl.py", line 111, in sendall
*args, **kwargs)
File "/home/brian_barnes/.local/lib/python2.7/site-packages/web/wsgiserver/ssl_pyopenssl.py", line 61, in _safe_call
return call(*args, **kwargs)
File "/home/brian_barnes/.local/lib/python2.7/site-packages/web/wsgiserver/__init__.py", line 913, in sendall
bytes_sent = self.send(data)
File "/home/brian_barnes/.local/lib/python2.7/site-packages/web/wsgiserver/ssl_pyopenssl.py", line 115, in send
*args, **kwargs)
File "/home/brian_barnes/.local/lib/python2.7/site-packages/web/wsgiserver/ssl_pyopenssl.py", line 77, in _safe_call
raise socket.error(errnum)
error: -1
环境: Ubuntu 18.04.1 LTS Python 2.7.15rc1 web.py: 0.39
有没有人遇到过这样的问题,或者知道是什么原因造成的。在 webpy.org 上阅读时。看来这是 0.36 版的问题,但 0.37 版应该没问题。我曾考虑过 0.40,但犹豫不决,因为它仍在开发中。
【问题讨论】:
-
可能是因为pyopenssl。试用内置的 ssl 适配器。
-
也许没有帮助,但我多年来一直像这样运行 web.py 0.38 没有问题(Ubuntu 14 和 16 .. 未尝试 18)。提供的 CherryPyWSGIServer 没有问题。
errnum的值是多少?那不会是-1。尝试捕获异常 socket.error 以查看详细信息(请参阅有关 socket.error 的文档)。 -
上游 CherryPy 的 WSGI 服务器 (Cheroot) 有许多错误,这些错误会被 SSL 连接忽略,但 web.py 似乎是供应商,因此没有收到任何更新/修复。
-
我一直在努力追根究底,并认为我是唯一看到它的人
-
@webKnajZ 不确定这是问题所在,我使用
import cherrypy看到同样的问题
标签: python https openssl cherrypy web.py