Exemplo n.º 1
0
Arquivo: app.py Projeto: mikazz/sorcer
def home():
    """
        Home
    """
    try:
        basic_connection = BasicConnection()
        basic_connection.connect()

    except Exception as e:
        response_object = {
            "status": "failed",
            "data": {
                "connection": "failed",
                "details": str(e)
            }
        }
    else:
        response_object = {
            "status": "success",
            "data": {
                "connection": "ok",
            }
        }

    return jsonify(response_object)
Exemplo n.º 2
0
def check_connect(host, port, password=None):
    from redis import Connection
    try:
        conn = Connection(host=host, port=port, password=password)
        conn.connect()
        return True
    except:
        return False
Exemplo n.º 3
0
def check_connect(host,port, password=None):
    from redis import Connection
    try:
        conn = Connection(host=host, port=port, password=password)
        conn.connect()
        return True
    except:
        return False
Exemplo n.º 4
0
def redis_container():
    session = docker.from_env()
    redis = session.containers.run('redis:latest',
                                   ports={'6379/tcp': 6379},
                                   detach=True)
    try:
        conn = Connection()
        for i in range(60):
            try:
                conn.connect()
                conn.disconnect()
                break
            except ConnectionError:
                pass

            if i == 59:
                raise RuntimeError('Failed to connect to Redis.')
            sleep(.5)

        yield redis
    finally:
        redis.remove(force=True, v=True)