许多 HTTP 请求导致 Bottle 服务器故障

Many HTTP requests cause Bottle server failure

我有以下代码:

@route('/my_page')
def my_page():
    conn = sqlite.connect('test.db')
    c = conn.cursor()
    c.execute("select * from table")
    res = c.fetchall()
    c.close()
    out = template('my_page',rows=res)
    return out

和具有自动刷新功能的模板my_page.tpl

<meta http-equiv="refresh" content="10">

我在浏览器中打开 http://my_server:8080/my_page,刷新几次后,我的应用出现以下错误:

File "c:\python27\lib\wsgiref\simple_server.py", line 116, in handle
    self.raw_requestline = self.rfile.readline()
  File "c:\python27\lib\socket.py", line 447, in readline
    data = self._sock.recv(self._rbufsize)
error: [Errno 10054] An existing connection was forcibly closed by the remote host

我需要重新启动我的应用程序才能使其再次运行。我还检查了 netstat -ano,我看到很多 TIME_WAIT TCP 连接。导致问题的原因是什么?

Bottle 默认服务器不适用于生产部署。为了提高稳定性和性能,建议 switch the server backend