'Wait for events of interest on registered file descriptors until an
event of interest occurs or next timer deadline or _MAX_POLL_TIMEOUT,
whichever is sooner, and dispatch the corresponding event handlers.'

def poll(self):

    while True:
        try:
            if (self._fd_events[READ] or self._fd_events[WRITE] or self._fd_events[ERROR]):
                (read, write, error) = select.select(self._fd_events[READ], self._fd_events[WRITE], self._fd_events[ERROR], self._get_next_deadline())
            else:
                time.sleep(self._get_next_deadline())
                (read, write, error) = ([], [], [])
            break
        except _SELECT_ERRORS as error:
            if _is_resumable(error):
                continue
            else:
                raise
    fd_event_map = defaultdict(int)
    for (fd_set, evt) in zip((read, write, error), (READ, WRITE, ERROR)):
        for fileno in fd_set:
            fd_event_map[fileno] |= evt
    self._dispatch_fd_events(fd_event_map)
