def get_redis_storage(): global _redis_storage if not _redis_storage: redis_config = config.get_redis_config() _redis_storage = redis.StrictRedis(**redis_config, decode_responses=True) return _redis_storage
async def _connect_async_redis(loop): redis_config = config.get_redis_config() address = f'redis://{redis_config["host"]}:{redis_config["port"]}' db = redis_config['db'] return await aioredis.create_redis( address=address, db=db, password=redis_config.get('password', None), loop=loop, )
return render_template("tasks_result.html", result=result) # the ServiceRpcProxy instance isn't thread safe so we constuct one for # each request; a more intelligent solution would be a thread-local or # pool of shared proxies def rpc_proxy(): URL = get_amqp_config() config = {'AMQP_URI': URL} return ServiceRpcProxy('tasks', config) # This section of the Code Starts-up your Flask Application. if __name__ == "__main__": (flask_hostname, flask_port, flask_debug) = get_rest_information() (redis_hostname, redis_port, redis_password) = get_redis_config() (postgres_database, postgres_user, postgres_password, postgres_host, postgres_port) = get_postgresql_config() if REDIS is None: REDIS = RedisHandler(host=redis_hostname, port=redis_port, password=redis_password) if POSTGRES is None: POSTGRES = PostgreSQL(database=postgres_database, user=postgres_user, password=postgres_password, host=postgres_host, port=postgres_port) app.run(host=flask_hostname, port=flask_port, debug=flask_debug)