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:
|
else:
|
||||||
flask_app = create_app()
|
flask_app = create_app()
|
||||||
|
|
||||||
red = RedisHandler(host=current_app.config.get('REDIS_HOST', 'localhost'),
|
red = RedisHandler().redis()
|
||||||
port=current_app.config.get('REDIS_PORT', 6379),
|
|
||||||
db=current_app.config.get('REDIS_DB', 0)).redis()
|
|
||||||
|
|
||||||
def make_celery(app):
|
def make_celery(app):
|
||||||
celery = Celery(
|
celery = Celery(
|
||||||
|
|
|
@ -3,14 +3,18 @@ Helper Class for Redis
|
||||||
|
|
||||||
"""
|
"""
|
||||||
import 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:
|
class RedisHandler:
|
||||||
#def __init__(self, host=current_app.config.get('REDIS_HOST', 'localhost'),
|
def __init__(self, host=flask_app.config.get('REDIS_HOST', 'localhost'),
|
||||||
# port=current_app.config.get('REDIS_PORT', 6379),
|
port=flask_app.config.get('REDIS_PORT', 6379),
|
||||||
# db=current_app.config.get('REDIS_DB', 0)):
|
db=flask_app.config.get('REDIS_DB', 0)):
|
||||||
def __init__(self, host, port, db):
|
|
||||||
self.host = host
|
self.host = host
|
||||||
self.port = port
|
self.port = port
|
||||||
self.db = db
|
self.db = db
|
||||||
|
|
Loading…
Reference in New Issue