当前位置: 首页>>代码示例>>Python>>正文


Python win32event.WAIT_TIMEOUT属性代码示例

本文整理汇总了Python中win32event.WAIT_TIMEOUT属性的典型用法代码示例。如果您正苦于以下问题:Python win32event.WAIT_TIMEOUT属性的具体用法?Python win32event.WAIT_TIMEOUT怎么用?Python win32event.WAIT_TIMEOUT使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在win32event的用法示例。


在下文中一共展示了win32event.WAIT_TIMEOUT属性的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: __windows_start_process__

# 需要导入模块: import win32event [as 别名]
# 或者: from win32event import WAIT_TIMEOUT [as 别名]
def __windows_start_process__(self, binary_path, task_key, verbose):
        import win32event
        out_stream = sys.stdout if verbose else open(os.devnull, 'w')
        loading_semaphore = win32event.CreateSemaphore(None, 0, 1,
                                                       'Global\\HOLODECK_LOADING_SEM' + self._uuid)
        self._world_process = \
            subprocess.Popen([binary_path, task_key, '-HolodeckOn', '-LOG=HolodeckLog.txt',
                              '-ForceRes', '-ResX=' + str(self._window_size[1]), '-ResY=' +
                              str(self._window_size[0]), '-TicksPerSec=' + str(self._ticks_per_sec),
                              '--HolodeckUUID=' + self._uuid],
                             stdout=out_stream, stderr=out_stream)

        atexit.register(self.__on_exit__)
        response = win32event.WaitForSingleObject(loading_semaphore, 100000)  # 100 second timeout
        if response == win32event.WAIT_TIMEOUT:
            raise HolodeckException("Timed out waiting for binary to load") 
开发者ID:BYU-PCCL,项目名称:holodeck,代码行数:18,代码来源:environments.py

示例2: testWaitableTrigger

# 需要导入模块: import win32event [as 别名]
# 或者: from win32event import WAIT_TIMEOUT [as 别名]
def testWaitableTrigger(self):
        h = win32event.CreateWaitableTimer(None, 0, None)
        # for the sake of this, pass a long that doesn't fit in an int.
        dt = -2000000000
        win32event.SetWaitableTimer(h, dt, 0, None, None, 0)
        rc = win32event.WaitForSingleObject(h, 10) # 10 ms.
        self.failUnlessEqual(rc, win32event.WAIT_TIMEOUT) 
开发者ID:IronLanguages,项目名称:ironpython2,代码行数:9,代码来源:test_win32event.py

示例3: testMsgWaitForMultipleObjects

# 需要导入模块: import win32event [as 别名]
# 或者: from win32event import WAIT_TIMEOUT [as 别名]
def testMsgWaitForMultipleObjects(self):
        # this function used to segfault when called with an empty list
        res = win32event.MsgWaitForMultipleObjects([], 0, 0, 0)
        self.assertEquals(res, win32event.WAIT_TIMEOUT) 
开发者ID:IronLanguages,项目名称:ironpython2,代码行数:6,代码来源:test_win32event.py

示例4: testMsgWaitForMultipleObjects2

# 需要导入模块: import win32event [as 别名]
# 或者: from win32event import WAIT_TIMEOUT [as 别名]
def testMsgWaitForMultipleObjects2(self):
        # test with non-empty list
        event = win32event.CreateEvent(None, 0, 0, None)
        res = win32event.MsgWaitForMultipleObjects([event], 0, 0, 0)
        self.assertEquals(res, win32event.WAIT_TIMEOUT) 
开发者ID:IronLanguages,项目名称:ironpython2,代码行数:7,代码来源:test_win32event.py

示例5: testMsgWaitForMultipleObjectsEx

# 需要导入模块: import win32event [as 别名]
# 或者: from win32event import WAIT_TIMEOUT [as 别名]
def testMsgWaitForMultipleObjectsEx(self):
        # this function used to segfault when called with an empty list
        res = win32event.MsgWaitForMultipleObjectsEx([], 0, 0, 0)
        self.assertEquals(res, win32event.WAIT_TIMEOUT) 
开发者ID:IronLanguages,项目名称:ironpython2,代码行数:6,代码来源:test_win32event.py

示例6: testMsgWaitForMultipleObjectsEx2

# 需要导入模块: import win32event [as 别名]
# 或者: from win32event import WAIT_TIMEOUT [as 别名]
def testMsgWaitForMultipleObjectsEx2(self):
        # test with non-empty list
        event = win32event.CreateEvent(None, 0, 0, None)
        res = win32event.MsgWaitForMultipleObjectsEx([event], 0, 0, 0)
        self.assertEquals(res, win32event.WAIT_TIMEOUT) 
开发者ID:IronLanguages,项目名称:ironpython2,代码行数:7,代码来源:test_win32event.py

示例7: connect_thread_runner

# 需要导入模块: import win32event [as 别名]
# 或者: from win32event import WAIT_TIMEOUT [as 别名]
def connect_thread_runner(self, expect_payload, giveup_event):
        # As Windows 2000 doesn't do ConnectEx, we need to use a non-blocking
        # accept, as our test connection may never come.  May as well use
        # AcceptEx for this...
        listener = socket.socket()
        self.addr = ('localhost', random.randint(10000,64000))
        listener.bind(self.addr)
        listener.listen(1)

        # create accept socket
        accepter = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
        # An overlapped
        overlapped = pywintypes.OVERLAPPED()
        overlapped.hEvent = win32event.CreateEvent(None, 0, 0, None)
        # accept the connection.
        if expect_payload:
            buf_size = 1024
        else:
            # when we don't expect data we must be careful to only pass the
            # exact number of bytes for the endpoint data...
            buf_size = win32file.CalculateSocketEndPointSize(listener)

        buffer = win32file.AllocateReadBuffer(buf_size)
        win32file.AcceptEx(listener, accepter, buffer, overlapped)
        # wait for the connection or our test to fail.
        events = giveup_event, overlapped.hEvent
        rc = win32event.WaitForMultipleObjects(events, False, 2000)
        if rc == win32event.WAIT_TIMEOUT:
            self.fail("timed out waiting for a connection")
        if rc == win32event.WAIT_OBJECT_0:
            # Our main thread running the test failed and will never connect.
            return
        # must be a connection.
        nbytes = win32file.GetOverlappedResult(listener.fileno(), overlapped, False)
        if expect_payload:
            self.request = buffer[:nbytes]
        accepter.send(str2bytes('some expected response')) 
开发者ID:IronLanguages,项目名称:ironpython2,代码行数:39,代码来源:test_win32file.py

示例8: is_modified

# 需要导入模块: import win32event [as 别名]
# 或者: from win32event import WAIT_TIMEOUT [as 别名]
def is_modified(self, buffer):
        print "path", self.path
        result = win32file.ReadDirectoryChangesW(
             self.handle,
             buffer,
             True,
                win32con.FILE_NOTIFY_CHANGE_FILE_NAME 
              | win32con.FILE_NOTIFY_CHANGE_DIR_NAME
              | win32con.FILE_NOTIFY_CHANGE_ATTRIBUTES
              | win32con.FILE_NOTIFY_CHANGE_SIZE
              | win32con.FILE_NOTIFY_CHANGE_LAST_WRITE
              | win32con.FILE_NOTIFY_CHANGE_SECURITY,
             self.overlapped,
            )
        print "result  1", result
        result = win32event.WaitForMultipleObjects([self.overlapped.hEvent], True, 0)
        print "result  2", result
        if result != win32event.WAIT_TIMEOUT:
#            result = win32file.GetOverlappedResult(self.handle, self.overlapped, False)
            return True
        else:
            return False


#===========================================================================
# Directory monitor class. 
开发者ID:t4ngo,项目名称:dragonfly,代码行数:28,代码来源:dirmon.py

示例9: doWaitForMultipleEvents

# 需要导入模块: import win32event [as 别名]
# 或者: from win32event import WAIT_TIMEOUT [as 别名]
def doWaitForMultipleEvents(self, timeout):
        log.msg(channel='system', event='iteration', reactor=self)
        if timeout is None:
            #timeout = INFINITE
            timeout = 100
        else:
            timeout = int(timeout * 1000)

        if not (self._events or self._writes):
            # sleep so we don't suck up CPU time
            time.sleep(timeout / 1000.0)
            return

        canDoMoreWrites = 0
        for fd in self._writes.keys():
            if log.callWithLogger(fd, self._runWrite, fd):
                canDoMoreWrites = 1

        if canDoMoreWrites:
            timeout = 0

        handles = self._events.keys() or [self.dummyEvent]
        val = MsgWaitForMultipleObjects(handles, 0, timeout, QS_ALLINPUT | QS_ALLEVENTS)
        if val == WAIT_TIMEOUT:
            return
        elif val == WAIT_OBJECT_0 + len(handles):
            exit = win32gui.PumpWaitingMessages()
            if exit:
                self.callLater(0, self.stop)
                return
        elif val >= WAIT_OBJECT_0 and val < WAIT_OBJECT_0 + len(handles):
            fd, action = self._events[handles[val - WAIT_OBJECT_0]]
            log.callWithLogger(fd, self._runAction, action, fd) 
开发者ID:kuri65536,项目名称:python-for-android,代码行数:35,代码来源:win32eventreactor.py

示例10: Write

# 需要导入模块: import win32event [as 别名]
# 或者: from win32event import WAIT_TIMEOUT [as 别名]
def Write(self, data, timeout):
        if self.handle:
            try:
                self.lockObject.acquire()
                if eg.debugLevel:
                    print "writing " + str(len(data)) + " bytes to " + self.getName()
                if not self._overlappedWrite:
                    self._overlappedWrite = win32file.OVERLAPPED()
                err, n = win32file.WriteFile(self.handle, data, self._overlappedWrite)
                if err:  #will be ERROR_IO_PENDING:
                    # Wait for the write to complete.
                    n = win32file.GetOverlappedResult(self.handle, self._overlappedWrite, 1)
                    if n != len(data):
                        raise Exception("could not write full data")
                elif n != len(data):
                    raise Exception("could not write full data")
                if timeout:  #waits for response from device
                    win32event.ResetEvent(self._overlappedRead.hEvent)
                    res = win32event.WaitForSingleObject(self._overlappedRead.hEvent, timeout)
                    if res == win32event.WAIT_TIMEOUT:
                        raise Exception("no response from device within timeout")
            finally:
                self.lockObject.release()
        else:
            raise Exception("invalid handle")
            return 
开发者ID:EventGhost,项目名称:EventGhost,代码行数:28,代码来源:HID.py


注:本文中的win32event.WAIT_TIMEOUT属性示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。