def __request_except(self, requestId, exc, set_and_forget=True):
        """Set exception (if not None) for the given request and (optionally) remove from internal cache & setting its
           event"""
        try:
            with self.__requests:
                if set_and_forget:
                    req = self.__requests.pop(requestId)
                else:
                    req = self.__requests[requestId]
        except KeyError:
            logger.error('Unknown request %s - cannot set exception', requestId)
        else:
            if exc is not None:
                req.exception = exc
            if set_and_forget:
                req._set()