mirror of
https://github.com/GSA/notifications-api.git
synced 2026-02-01 07:35:34 -05:00
Merge pull request #2242 from alphagov/enable-sa-preping
Enable pessimistic DB connection disconnect handling
This commit is contained in:
@@ -4,7 +4,7 @@ import string
|
|||||||
import uuid
|
import uuid
|
||||||
|
|
||||||
from flask import _request_ctx_stack, request, g, jsonify
|
from flask import _request_ctx_stack, request, g, jsonify
|
||||||
from flask_sqlalchemy import SQLAlchemy
|
from flask_sqlalchemy import SQLAlchemy as _SQLAlchemy
|
||||||
from flask_marshmallow import Marshmallow
|
from flask_marshmallow import Marshmallow
|
||||||
from flask_migrate import Migrate
|
from flask_migrate import Migrate
|
||||||
from time import monotonic
|
from time import monotonic
|
||||||
@@ -27,6 +27,13 @@ from app.encryption import Encryption
|
|||||||
DATETIME_FORMAT = "%Y-%m-%dT%H:%M:%S.%fZ"
|
DATETIME_FORMAT = "%Y-%m-%dT%H:%M:%S.%fZ"
|
||||||
DATE_FORMAT = "%Y-%m-%d"
|
DATE_FORMAT = "%Y-%m-%d"
|
||||||
|
|
||||||
|
|
||||||
|
class SQLAlchemy(_SQLAlchemy):
|
||||||
|
def apply_pool_defaults(self, app, options):
|
||||||
|
_SQLAlchemy.apply_pool_defaults(self, app, options)
|
||||||
|
options["pool_pre_ping"] = True
|
||||||
|
|
||||||
|
|
||||||
db = SQLAlchemy()
|
db = SQLAlchemy()
|
||||||
migrate = Migrate()
|
migrate = Migrate()
|
||||||
ma = Marshmallow()
|
ma = Marshmallow()
|
||||||
|
|||||||
Reference in New Issue
Block a user