def METHOD_NAME(container, timeout=30):
    threshold = time.time() + timeout
    ready_msg = "database system is ready to accept connections"
    while True:
        lines = container.logs().decode()
        # container fully ready
        # because it reloads the db server during initialization
        # need to check that the 'ready for connections' has found second time
        if lines.count(ready_msg) > 1:
            break
        if time.time() > threshold:
            raise Exception("timeout exceeded, container is still not ready")