def waitForEvents(self, timeout):
from win32api import GetCurrentThreadId
from win32event import INFINITE
from win32event import MsgWaitForMultipleObjects, \
QS_ALLINPUT, WAIT_TIMEOUT, WAIT_OBJECT_0
from pythoncom import PumpWaitingMessages
import types
if not isinstance(timeout, int):
raise TypeError("The timeout argument is not an integer")
if self.tid != GetCurrentThreadId():
raise Exception("wait for events from the same thread you inited!")
if timeout < 0:
cMsTimeout = INFINITE
else:
cMsTimeout = timeout
rc = MsgWaitForMultipleObjects(self.handles, 0, cMsTimeout, QS_ALLINPUT)
if WAIT_OBJECT_0 <= rc < WAIT_OBJECT_0 + len(self.handles):
# is it possible?
rc = 2
elif rc == WAIT_OBJECT_0 + len(self.handles):
# Waiting messages
PumpWaitingMessages()
rc = 0
else:
# Timeout
rc = 1
# check for interruption
self.oIntCv.acquire()
if self.fInterrupted:
self.fInterrupted = False
rc = 1
self.oIntCv.release()
return rc
__init__.py 文件源码
python
阅读 24
收藏 0
点赞 0
评论 0
评论列表
文章目录