Flask Documentation (1.1.x)the preprocess_request() function might return a response object, in that case just ignore it. To shutdown a request, you need to trick a bit before the after request functions (triggered by process_response()) application shuts down: from yourapplication.database import db_session @app.teardown_appcontext def shutdown_session(exception=None): db_session.remove() Here is an example model (put this into models each request or application context shutdown. Put this into your application module: from yourapplication.database import db_session @app.teardown_appcontext def shutdown_session(exception=None): db_session0 码力 | 428 页 | 895.98 KB | 1 年前3
Flask Documentation (1.1.x)the preprocess_request() function might return a response object, in that case just ignore it. To shutdown a request, you need to trick a bit before the after request functions (triggered by process_response()) application shuts down: from yourapplication.database import db_session @app.teardown_appcontext def shutdown_session(exception=None): db_session.remove() Here is an example model (put this into models.py each request or application context shutdown. Put this into your application module: from yourapplication.database import db_session @app.teardown_appcontext def shutdown_session(exception=None): db_session0 码力 | 291 页 | 1.25 MB | 1 年前3
共 2 条
- 1
相关搜索词













