def wait_for(proc, port_num):
    trys = 0
    while proc.poll() is None and trys < 160:
        trys += 1
        s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
        try:
            try:
                s.connect((hostname, port_num))
                return True
            except (__HOLE__, socket.error):
                time.sleep(0.25)
        finally:
            s.close()

    kill_all_members()
    return False
dataset/ETHPy150Open mongodb/motor/test/high_availability/ha_tools.py/wait_for