code: def set_result(self, result):
          
          result = result.result()[0]
          if self.future is not None:
              if isinstance(result, Exception):
                  self.future.set_exception(result)
              else:
                  self.future.set_result(result)
              self.future = None
          elif isinstance(result, Exception):
              raise result
docs: Set future's result if needed (can be an exception).
          Else raise if needed.