fixing the app context issue. we will create an app if no current_app available
This commit is contained in:
parent
2628ed1a82
commit
97d74bfa1d
|
@ -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(
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue