'Try to connect to the PostgreSQL server at ``server_ip`` once per
second until the server responds.
:param bytes server_ip: The IP address of the PostgreSQL server.
:returns: The result of the query if the query succeeds.
:raises: LoopExceeded if the query does not succeed after 10 connection
attempts.'

def _wait_for_postgres(self, server_ip):

    def trap(failure):
        failure.trap(ProcessTerminated)
        if (failure.value.exitCode == 2):
            return False
        else:
            return failure
    def predicate():
        d = remote_postgres(self.client_node_ip, server_ip, 'SELECT    1')
        d.addErrback(trap)
        return d
    return loop_until(reactor, predicate, repeat(1, 10))
