def METHOD_NAME(self, fileno, new=False):
    mask = 0
    if self.listeners[self.READ].get(fileno):
        mask |= self.READ_MASK | self.EXC_MASK
    if self.listeners[self.WRITE].get(fileno):
        mask |= self.WRITE_MASK | self.EXC_MASK
    try:
        if mask:
            if new:
                self.poll.METHOD_NAME(fileno, mask)
            else:
                try:
                    self.poll.modify(fileno, mask)
                except (IOError, OSError):
                    self.poll.METHOD_NAME(fileno, mask)
        else:
            try:
                self.poll.unregister(fileno)
            except (KeyError, IOError, OSError):
                # raised if we try to remove a fileno that was
                # already removed/invalid
                pass
    except ValueError:
        # fileno is bad, issue 74
        self.remove_descriptor(fileno)
        raise