fixing the app context issue. we will create an app if no current_app available

This commit is contained in:
Hossein Shafagh 2019-07-12 08:47:39 -07:00
parent 2628ed1a82
commit 97d74bfa1d
2 changed files with 11 additions and 8 deletions

View File

@ -32,9 +32,8 @@ if current_app:
else:
flask_app = create_app()
red = RedisHandler(host=current_app.config.get('REDIS_HOST', 'localhost'),
port=current_app.config.get('REDIS_PORT', 6379),
db=current_app.config.get('REDIS_DB', 0)).redis()
red = RedisHandler().redis()
def make_celery(app):
celery = Celery(

View File

@ -3,14 +3,18 @@ Helper Class for Redis
"""
import redis
#from flask import current_app
from flask import current_app
from lemur.factory import create_app
if current_app:
flask_app = current_app
else:
flask_app = create_app()
class RedisHandler:
#def __init__(self, host=current_app.config.get('REDIS_HOST', 'localhost'),
# port=current_app.config.get('REDIS_PORT', 6379),
# db=current_app.config.get('REDIS_DB', 0)):
def __init__(self, host, port, db):
def __init__(self, host=flask_app.config.get('REDIS_HOST', 'localhost'),
port=flask_app.config.get('REDIS_PORT', 6379),
db=flask_app.config.get('REDIS_DB', 0)):
self.host = host
self.port = port
self.db = db