1
我正在用flask和sqlalchemy使用PostgreSQL作为RDB开发应用程序。
我很好奇当请求完成时,PostgreSQL不会拆卸事务空闲。如何在Flask和SQLAlchemy上完全关闭postgresql事务空闲?
下面是拆解PostgreSQL的交易代码在烧瓶:
@app.after_request
def after_request(r):
db.dispose()
session.close()
但我仍可以看到PostgreSQL的闲置交易的过程。
$ ps axu | grep postgres
postgres 18127 0.9 1.0 326348 6612 ? Ss 11:08 0:00 postgres: postgres mydb ::1(59013) idle
如何在应用程序代码中终止进程?