'Poll the IO completion port for new events.'

def doIteration(self, timeout):

    processed_events = 0
    if (timeout is None):
        timeout = MAX_TIMEOUT
    else:
        timeout = min(MAX_TIMEOUT, int((1000 * timeout)))
    (rc, numBytes, key, evt) = self.port.getEvent(timeout)
    while 1:
        if (rc == WAIT_TIMEOUT):
            break
        if (key != KEY_WAKEUP):
            assert (key == KEY_NORMAL)
            log.callWithLogger(evt.owner, self._callEventCallback, rc, numBytes, evt)
            processed_events += 1
        if (processed_events >= EVENTS_PER_LOOP):
            break
        (rc, numBytes, key, evt) = self.port.getEvent(0)
