'Private method for removing a descriptor from the event loop.
It does the inverse job of _add, and also add a check in case of the fd
has gone away.'

def _remove(self, xer, primary, other, selectables, event, antievent):

    fd = xer.fileno()
    if (fd == (-1)):
        for (fd, fdes) in selectables.items():
            if (xer is fdes):
                break
        else:
            return
    if (fd in primary):
        if (fd in other):
            flags = antievent
            self._poller.modify(fd, flags)
        else:
            del selectables[fd]
            self._poller.unregister(fd)
        primary.remove(fd)
