edfexecution.py 文件源码

python
阅读 24 收藏 0 点赞 0 评论 0

项目:isf 作者: w3h 项目源码 文件源码
def connect_pipe(pipe, pipeName):
        overLap = pywintypes.OVERLAPPED()
        overLap.hEvent = win32event.CreateEvent(None, 1, 0, None)
        if overLap.hEvent == 0:
            raise PipeError('Could not create hEvent')

        try:
            # Wait for a pipe client connection
            ret = win32pipe.ConnectNamedPipe(pipe, overLap)
            if not ret in (0, ERROR_PIPE_CONNECTED):
                if ret == ERROR_IO_PENDING:
                    ret = win32event.WaitForSingleObject(overLap.hEvent, 
                                                         1000 * CONNECT_TIMEOUT_SECS)
                    if ret != win32event.WAIT_OBJECT_0:
                        # Timeout error
                        raise PipeError('Timeout error')
                else:
                    # API error
                    raise PipeError('API error')

                ret = win32pipe.GetOverlappedResult(pipe, overLap, True)
            if not ret in (0, ERROR_PIPE_CONNECTED):
                # API Error
                raise PipeError('API error 2')
        except PipeError:
            # Named pipe exception
            win32file.CancelIo(pipe)
            pipe.close()
            raise
        except BaseException, err:
            win32file.CancelIo(pipe)
            pipe.close()
            pipe = None
            raise PipeError('BaseException : ' + str(err))

        return pipe
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号