WSGI: Use current_app if it's available, otherwise make it available
ARA leverages the Flask application context heavily to share data and configuration between requests and components. The WSGI script always created new application contexts and didn't re-use the current application context if it existed in memory. Change-Id: Ice93125fd4711cb0d22233c99eb354a0d688092e
This commit is contained in:
parent
259d3bed08
commit
fa624de6f7
13
ara/wsgi.py
13
ara/wsgi.py
|
@ -21,7 +21,11 @@
|
|||
import os
|
||||
import logging
|
||||
|
||||
from ara.webapp import create_app
|
||||
from flask import current_app
|
||||
|
||||
log = logging.getLogger(__name__)
|
||||
app = create_app()
|
||||
|
||||
|
||||
def application(environ, start_response):
|
||||
|
@ -31,9 +35,12 @@ def application(environ, start_response):
|
|||
if 'ANSIBLE_CONFIG' not in os.environ:
|
||||
log.warn('ANSIBLE_CONFIG environment variable not found.')
|
||||
|
||||
from ara.webapp import create_app
|
||||
app = create_app()
|
||||
return app(environ, start_response)
|
||||
if not current_app:
|
||||
ctx = app.app_context()
|
||||
ctx.push()
|
||||
return app(environ, start_response)
|
||||
else:
|
||||
return current_app(environ, start_response)
|
||||
|
||||
|
||||
def main():
|
||||
|
|
Loading…
Reference in New Issue