mirror of
https://github.com/GSA/notifications-api.git
synced 2025-12-08 22:22:24 -05:00
try to lazy init db another way
This commit is contained in:
@@ -88,9 +88,10 @@ encryption = None
|
||||
zendesk_client = None
|
||||
redis_store = RedisClient()
|
||||
document_download_client = None
|
||||
notification_provider_clients = None
|
||||
|
||||
notification_provider_clients = NotificationProviderClients()
|
||||
|
||||
# LocalProxy doesn't evaluate the target immediately, but defers
|
||||
# resolution to runtime. So there is no monkeypatching concern.
|
||||
api_user = LocalProxy(lambda: g.api_user)
|
||||
authenticated_service = LocalProxy(lambda: g.authenticated_service)
|
||||
|
||||
@@ -181,10 +182,12 @@ def create_app(application):
|
||||
logging.init_app(application)
|
||||
|
||||
# start lazy initialization for gevent
|
||||
# NOTE: notify_celery and redis_store are safe to construct here
|
||||
# because all entry points (gunicorn_entry.py, run_celery.py) apply
|
||||
# monkey.patch_all() first.
|
||||
# Do NOT access or use them before create_app() is called and don't
|
||||
# call create_app() in multiple places.
|
||||
|
||||
# Set db engine settings here for now.
|
||||
# They were not being set previous (despite environmental variables with appropriate
|
||||
# sounding names) and were defaulting to low values
|
||||
db = SQLAlchemy(
|
||||
engine_options={
|
||||
"pool_size": config.Config.SQLALCHEMY_POOL_SIZE,
|
||||
@@ -213,9 +216,7 @@ def create_app(application):
|
||||
aws_sns_client.init_app(application)
|
||||
encryption = Encryption()
|
||||
encryption.init_app(application)
|
||||
|
||||
# end lazy initialization
|
||||
|
||||
notification_provider_clients = NotificationProviderClients()
|
||||
# If a stub url is provided for SES, then use the stub client rather than the real SES boto client
|
||||
email_clients = (
|
||||
[aws_ses_stub_client]
|
||||
@@ -225,6 +226,7 @@ def create_app(application):
|
||||
notification_provider_clients.init_app(
|
||||
sms_clients=[aws_sns_client], email_clients=email_clients
|
||||
)
|
||||
# end lazy initialization
|
||||
|
||||
notify_celery.init_app(application)
|
||||
redis_store.init_app(application)
|
||||
|
||||
Reference in New Issue
Block a user