简体   繁体   中英

Server Flask app with cheroot server results to error in HTTPServer.tick after each request

I'm trying to serve a Flask (v1.1.2) wsgi application using cheroot server of CherryPy (v18.6.0) and after each request executed via Postman or browser I'm getting the following exception in my console. I'm running 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

Code as follows:

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()

Any idea causing that exception and how we can resolve it?

This is a recent and acknowledged issue with cheroot, take a look to the cheroot GitHub Issue 312 .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM