def result(self, timeout=None):
        """Wait for the future to complete and return its result.

        If the function returned normally, its return value is returned here.
        If the function raised an exception, the exception is re-raised here.
        """
        if not self._done.wait(timeout):
            raise Timeout('timeout waiting for future')
        # No more state changes after _done is set so no lock needed.
        if self._state == self.S_EXCEPTION:
            raise compat.saved_exc(self._result)
        return self._result
Wait for the future to complete and return its result.

        If the function returned normally, its return value is returned here.
        If the function raised an exception, the exception is re-raised here.