def create_celery_app(app=None): from sqlalchemy import create_engine from sqlalchemy.orm import sessionmaker app = create_app() celery = Celery(app.__class__) celery.config_from_object('celery_config') TaskBase = celery.Task class ContextTask(TaskBase): abstract = True def __call__(self, *args, **kwargs): with app.app_context(): return TaskBase.__call__(self, *args, **kwargs) celery.Task = ContextTask #celery.conf.update(app.config) app.app_context().push() # an Engine, which the Session will use for connection # resources celery_task = create_engine(app.config['SQLALCHEMY_DATABASE_URI']) # create a configured "Session" class Session = sessionmaker(bind=celery_task) # create a Session session = Session() return celery, session
def CreateApp(): app = Flask(__name__) app.config.from_object('config') celery.config_from_object('config') InitmongoDB(app) InitLogin(app) RegisterBlueprints(app) return app
def create_app(config=None): app = Flask('scaffold', instance_relative_config=True) if config is not None: app.config.from_object(config) init_logger(app) logger.info('starting %s' % app.name) db.init_app(app) cors.init_app(app) celery.config_from_object(app.config) login_manager.init_app(app) api.init_app(app) init_api(api, app) logger.info('started %s' % app.name) return app
def create_app(config_name): app = Flask(__name__) app.config.from_object(config[config_name]) config[config_name].init_app(app) bootstrap.init_app(app) mail.init_app(app) moment.init_app(app) db.init_app(app) login_manager.init_app(app) celery.config_from_object(app.config) from .main import main as main_blueprint app.register_blueprint(main_blueprint) from .auth import auth as auth_blueprint app.register_blueprint(auth_blueprint, url_prefix='/auth') return app
def create_celery_app(app=None): from sqlalchemy import create_engine from sqlalchemy.orm import sessionmaker app = create_app() celery = Celery(app.__class__) celery.config_from_object('celery_config') TaskBase = celery.Task class ContextTask(TaskBase): abstract = True def __call__(self, *args, **kwargs): with app.app_context(): return TaskBase.__call__(self, *args, **kwargs) celery.Task = ContextTask #celery.conf.update(app.config) app.app_context().push() # an Engine, which the Session will use for connection # resources celery_task = create_engine(app.config['SQLALCHEMY_DATABASE_URI']) # create a configured "Session" class Session = sessionmaker(bind=celery_task) # create a Session session = Session() return celery , session
from app import create_app from extensions import celery from celery_task_socket import self_test import eventlet ''' Enable the monkey_patch if run into a socket issue ''' #eventlet.monkey_patch() app = create_app() celery.init_app(app) celery.config_from_object('celery_socket_config')
from app import create_app from extensions import celery from celery_task_socket import self_test import eventlet ''' Enable the monkey_patch if run into a socket issue ''' eventlet.monkey_patch() app = create_app() celery.init_app(app) celery.config_from_object('celery_socket_config')
from prod import config except: pass from functools import wraps from utils import convert from extensions import celery, db from requests import post from flask_socketio import SocketIO from statistics import mean #import app #tapp,session = app.create_socket_celery() # celery.init_app(tapp) celery.config_from_object('celery_config') logger = logging.getLogger('task') logger.setLevel(10) #celery, session = create_celery_app() #celery.config_from_object('prod', silent=True) # load config from celery_config.py , store other api information in prod.py indbapi = Indb(config['INDB_HOST'] + ':' + config['INDB_PORT']) sensuapi = SensuAPI(config['SENSU_HOST'] + ':' + config['SENSU_PORT']) #master = session.query(Masterdb).first() # try:
def configure_app(app): app.config.from_object("conf") celery.config_from_object(app.config)