def __init__()

in nailgun-client/py/ng.py [0:0]


    def __init__(self, sockpath):
        self.sockpath = u"\\\\.\\pipe\\{0}".format(sockpath)

        while True:
            self.pipe = CreateFile(
                self.sockpath,
                GENERIC_READ | GENERIC_WRITE,
                0,
                None,
                OPEN_EXISTING,
                FILE_FLAG_OVERLAPPED,
                None,
            )
            err1 = GetLastError()
            msg = _win32_strerror(err1)
            if self.pipe != INVALID_HANDLE_VALUE:
                break
            if err1 != ERROR_PIPE_BUSY:
                self.pipe = None
                raise NailgunException(msg, NailgunException.CONNECT_FAILED)
            if not WaitNamedPipe(self.sockpath, 5000):
                self.pipe = None
                raise NailgunException(
                    "time out while waiting for a pipe", NailgunException.CONNECT_FAILED
                )

        # event for the overlapped I/O operations
        self.read_waitable = CreateEvent(None, True, False, None)
        if self.read_waitable is None:
            raise NailgunException(
                "CreateEvent failed", NailgunException.CONNECT_FAILED
            )
        self.write_waitable = CreateEvent(None, True, False, None)
        if self.write_waitable is None:
            raise NailgunException(
                "CreateEvent failed", NailgunException.CONNECT_FAILED
            )