'fd is available for read or write, do the work and raise errors if
necessary.'

def _doReadOrWrite(self, selectable, fd, event):

    why = None
    inRead = False
    if ((event & self._POLL_DISCONNECTED) and (not (event & self._POLL_IN))):
        if (fd in self._reads):
            inRead = True
            why = CONNECTION_DONE
        else:
            why = CONNECTION_LOST
    else:
        try:
            if (selectable.fileno() == (-1)):
                why = _NO_FILEDESC
            else:
                if (event & self._POLL_IN):
                    why = selectable.doRead()
                    inRead = True
                if ((not why) and (event & self._POLL_OUT)):
                    why = selectable.doWrite()
                    inRead = False
        except:
            why = sys.exc_info()[1]
            log.err()
    if why:
        self._disconnectSelectable(selectable, why, inRead)
