0

我正在尝试使用 CherryPy (v18.6.0) 的 cheroot 服务器为 Flask (v1.1.2) wsgi 应用程序提供服务,并且在通过 Postman 或浏览器执行每个请求后,我在控制台中收到以下异常。我正在运行 python v3.8.5

Error in HTTPServer.tick
Traceback (most recent call last):
    File "C:\myproject\venv\lib\site-packages\cheroot\server.py", line 1795, in serve
self.tick()
    File "C:\myproject\venv\lib\site-packages\cheroot\server.py", line 2030, in tick
self.connections.expire()
    File "C:\myproject\venv\lib\site-packages\cheroot\connections.py", line 107, in expire
for sock_fd, conn in timed_out_connections:
    File "C:\myproject\venv\lib\site-packages\cheroot\connections.py", line 103, in <genexpr>
(sock_fd, conn)
    File "C:\python\lib\_collections_abc.py", line 743, in __iter__
for key in self._mapping:
RuntimeError: dictionary changed size during iteration

代码如下:

from cheroot.wsgi import Server
from flask import Flask

app = Flask(__name__)

@app.route("/", methods=["GET"])
def index():
    return "Hello"

if __name__ == "__main__":
    server = Server(bind_addr=("0.0.0.0", 3000), wsgi_app=app)
    try:
         server.start()
    finally:
         server.stop()

任何导致该异常的想法以及我们如何解决它?

4

1 回答 1

2

这是 cheroot 近期公认的问题,请查看cheroot GitHub 问题 312

于 2020-08-18T17:45:02.727 回答