# Path: postgraas_server/backends/docker/postgres_instance_driver.py
# def _docker_client():
#     return docker.DockerClient(base_url='unix://var/run/docker.sock', version='auto', timeout=30)


import time
from postgraas_server.backends.docker.postgres_instance_driver import _docker_client



def wait_for_postgres_listening(container_id, timeout=10):
    """
    Inspect/follow the output of the docker container logs until encountering the
    message from postgres that it accepts connections.

    Raises in case the container does not exist.

    Caveat: this check is specific to the used docker image.
    Tested for current postgres:9.4 image.

    :returns: boolean, whether the message has been (True), or the timeout has been hit (False).
    """

# Path: postgraas_server/backends/docker/postgres_instance_driver.py
# def _docker_client():
#     return docker.DockerClient(base_url='unix://var/run/docker.sock', version='auto', timeout=30)


# Path: tests/test_integration/utils.py
import time
from postgraas_server.backends.docker.postgres_instance_driver import _docker_client




def wait_for_postgres_listening(container_id, timeout=10):
    """
    Inspect/follow the output of the docker container logs until encountering the
    message from postgres that it accepts connections.

    Raises in case the container does not exist.

    Caveat: this check is specific to the used docker image.
    Tested for current postgres:9.4 image.

    :returns: boolean, whether the message has been (True), or the timeout has been hit (False).
    """

    c = _docker_client()