<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def result(self, raise_exception=True):
 """Waits until TransferFuture is done and returns the result If the TransferFuture succeeded, it will return the result. If the TransferFuture failed, it will raise the exception associated to the failure. """

        _status = None
        _exception = None
        self._done_event.wait(MAXINT)  # first wait for session global
        if self.is_failed():  # global exception set
            _exception = self._exception
            _status = enumAsperaControllerStatus.FAILED
        else:
            for _session in self._sessions.values():
                _status_tmp, _exception_tmp = _session.wait()
                if _exception_tmp and not _exception:
                    _exception = _exception_tmp
                    _status = _status_tmp

        # Once done waiting, raise an exception if present or return the final status
        if _exception and raise_exception:
            raise _exception

        return _status