def doWaitForMultipleEvents(self, timeout,
reads=reads,
writes=writes):
log.msg(channel='system', event='iteration', reactor=self)
if timeout is None:
#timeout = INFINITE
timeout = 100
else:
timeout = int(timeout * 1000)
if not (events or writes):
# sleep so we don't suck up CPU time
time.sleep(timeout / 1000.0)
return
canDoMoreWrites = 0
for fd in writes.keys():
if log.callWithLogger(fd, self._runWrite, fd):
canDoMoreWrites = 1
if canDoMoreWrites:
timeout = 0
handles = 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 = events[handles[val - WAIT_OBJECT_0]]
log.callWithLogger(fd, self._runAction, action, fd)
评论列表
文章目录