(self, exception)
Sets the result of the future as being the given exception.

        Should only be used by Executor implementations and unit tests.
Sets the result of the future as being the given exception.
Sets the result of the future as being the given exception .
def set_exception(self, exception):
        """Sets the result of the future as being the given exception.

        Should only be used by Executor implementations and unit tests.
        """
        with self._condition:
            if self._state in {CANCELLED, CANCELLED_AND_NOTIFIED, FINISHED}:
                raise InvalidStateError('{}: {!r}'.format(self._state, self))
            self._exception = exception
            self._state = FINISHED
            for waiter in self._waiters:
                waiter.add_exception(self)
            self._condition.notify_all()
        self._invoke_callbacks()
def set_exception ( self , exception ) : with self . _condition : if self . _state in { CANCELLED , CANCELLED_AND_NOTIFIED , FINISHED } : raise InvalidStateError ( '{}: {!r}' . format ( self . _state , self ) ) self . _exception = exception self . _state = FINISHED for waiter in self . _waiters : waiter . add_exception ( self ) self . _condition . notify_all ( ) self . _invoke_callbacks ( )