def result(self, timeout=None): """Returns the result of the call that the future represents. :param timeout: The number of seconds to wait for the result if the future has not been completed. None, the default, sets no limit. :returns: The result of the call that the future represents. :raises: TimeoutError: If the timeout is reached before the future ends execution. :raises: Exception: If the call raises the Exception. """ with self.__condition: if self.__state == FINISHED: return self.__get__result() lock = get_lock() if lock is not None: lock.release() self.__condition.wait(timeout) if lock is not None: lock.acquire() if self.__state == FINISHED: return self.__get__result() else: raise TimeoutError('Future: %r' % self.__method)