'Set the handler\'s events to the given events; internal to
`_PollerBase`.
:param int fileno: The file descriptor
:param int events: The event mask (READ, WRITE, ERROR)
:returns: a 2-tuple (events_cleared, events_set)'

def _set_handler_events(self, fileno, events):

    events_cleared = 0
    events_set = 0
    for evt in (READ, WRITE, ERROR):
        if (events & evt):
            if (fileno not in self._fd_events[evt]):
                self._fd_events[evt].add(fileno)
                events_set |= evt
        elif (fileno in self._fd_events[evt]):
            self._fd_events[evt].discard(fileno)
            events_cleared |= evt
    return (events_cleared, events_set)
