def set_callback (self, callback, reqid = None, timeout = None):
        if reqid is not None:
            self._meta ["__reqid"] = reqid

        if self._cv:
            with self._cv:
                requests = self._requests
                self._callback = callback
        else:
            # already finished or will use cache
            requests = self._requests
            self._callback = callback

        if not requests:
            return self._do_callback (callback)
        timeout and self.reset_timeout (timeout)