teardown_request()如何与Python Flask一起工作?

2024-05-14 00:51:43 发布

您现在位置:Python中文网/ 问答频道 /正文

我收到内部错误消息:

"TimeoutError: QueuePool limit of size 5 overflow 10 reached, connection timed out, timeout 30"

在线搜索提供了teardown_request()解决方案:

@app.teardown_request
def checkin_db(exc):
    try:
        print "Removing db session."
        db.session.remove()
    except AttributeError:
        pass

现在超时错误消失了。但我不完全理解teardown_请求,看起来每次请求后都会调用db.session.remove()吗?或者每一个错误?使用这个密码安全吗?


Tags: of消息dbsizerequestsession错误connection