Ticket #6217: reactor.py.diff
| File reactor.py.diff, 1.6 KB (added by BrianMatthews, 5 months ago) |
|---|
-
.py
old new 94 94 # here and GetQueuedCompletionStatus in a thread. Or I could poll with 95 95 # a reasonable interval. Guess what! Threads are hard. 96 96 97 processed_events = 098 97 if timeout is None: 99 98 timeout = MAX_TIMEOUT 100 99 else: 101 100 timeout = min(MAX_TIMEOUT, int(1000*timeout)) 102 rc, bytes, key, evt = self.port.getEvent(timeout) 103 while 1: 104 if rc == WAIT_TIMEOUT: 105 break 106 if key != KEY_WAKEUP: 107 assert key == KEY_NORMAL 108 log.callWithLogger(evt.owner, self._callEventCallback, 109 rc, bytes, evt) 110 processed_events += 1 111 if processed_events >= EVENTS_PER_LOOP: 112 break 113 rc, bytes, key, evt = self.port.getEvent(0) 101 # pull all the existing events 102 events = [] 103 event = self.port.getEvent(timeout) 104 while event[0] != WAIT_TIMEOUT: 105 if event[2] == KEY_NORMAL: 106 events.append(event) 107 event = self.port.getEvent(0) 114 108 109 #process them 110 for (rc, bytes, key, evt) in events: 111 log.callWithLogger(evt.owner, self._callEventCallback, 112 rc, bytes, evt) 115 113 114 116 115 def _callEventCallback(self, rc, bytes, evt): 117 116 owner = evt.owner 118 117 why = None
