Public Member Functions | List of all members
grpc.Future Class Reference
Inheritance diagram for grpc.Future:
Inheritance graph
[legend]

Public Member Functions

def add_done_callback (self, fn)
 
def cancel (self)
 
def cancelled (self)
 
def done (self)
 
def exception (self, timeout=None)
 
def result (self, timeout=None)
 
def running (self)
 
def traceback (self, timeout=None)
 

Detailed Description

A representation of a computation in another control flow.

Computations represented by a Future may be yet to be begun,
may be ongoing, or may have already completed.

Definition at line 48 of file src/python/grpcio/grpc/__init__.py.

Member Function Documentation

◆ add_done_callback()

def grpc.Future.add_done_callback (   self,
  fn 
)
Adds a function to be called at completion of the computation.

The callback will be passed this Future object describing the outcome
of the computation.  Callbacks will be invoked after the future is
terminated, whether successfully or not.

If the computation has already completed, the callback will be called
immediately.

Exceptions raised in the callback will be logged at ERROR level, but
will not terminate any threads of execution.

Args:
  fn: A callable taking this Future object as its single parameter.

Reimplemented in grpc._channel._MultiThreadedRendezvous, grpc._channel._SingleThreadedRendezvous, grpc_testing._channel._invocation._FutureCall, grpc._interceptor._UnaryOutcome, grpc._utilities._ChannelReadyFuture, grpc._interceptor._FailureOutcome, grpc_testing._time._Future, and default_value_client_interceptor._ConcreteValue.

Definition at line 189 of file src/python/grpcio/grpc/__init__.py.

◆ cancel()

def grpc.Future.cancel (   self)
Attempts to cancel the computation.

This method does not block.

Returns:
    bool:
    Returns True if the computation was canceled.

    Returns False under all other circumstances, for example:

    1. computation has begun and could not be canceled.
    2. computation has finished
    3. computation is scheduled for execution and it is impossible
to determine its state without blocking.

Reimplemented in grpc._channel._InactiveRpcError, grpc_testing._channel._invocation._FutureCall, grpc._interceptor._UnaryOutcome, grpc._interceptor._FailureOutcome, grpc._utilities._ChannelReadyFuture, grpc_testing._time._Future, and default_value_client_interceptor._ConcreteValue.

Definition at line 56 of file src/python/grpcio/grpc/__init__.py.

◆ cancelled()

def grpc.Future.cancelled (   self)
Describes whether the computation was cancelled.

This method does not block.

Returns:
    bool:
    Returns True if the computation was cancelled before its result became
    available.

    Returns False under all other circumstances, for example:

    1. computation was not cancelled.
    2. computation's result is available.

Reimplemented in grpc._channel._MultiThreadedRendezvous, grpc._channel._SingleThreadedRendezvous, grpc._channel._InactiveRpcError, grpc_testing._channel._invocation._FutureCall, grpc._interceptor._UnaryOutcome, grpc._utilities._ChannelReadyFuture, grpc._interceptor._FailureOutcome, grpc_testing._time._Future, and default_value_client_interceptor._ConcreteValue.

Definition at line 75 of file src/python/grpcio/grpc/__init__.py.

◆ done()

def grpc.Future.done (   self)
Describes whether the computation has taken place.

This method does not block.

Returns:
    bool:
    Returns True if the computation already executed or was cancelled.
    Returns False if the computation is scheduled for execution or
    currently executing.
    This is exactly opposite of the running() method's result.

Reimplemented in grpc._channel._MultiThreadedRendezvous, grpc._channel._SingleThreadedRendezvous, grpc._channel._InactiveRpcError, grpc_testing._channel._invocation._FutureCall, grpc._interceptor._UnaryOutcome, grpc._utilities._ChannelReadyFuture, grpc._interceptor._FailureOutcome, grpc_testing._time._Future, and default_value_client_interceptor._ConcreteValue.

Definition at line 107 of file src/python/grpcio/grpc/__init__.py.

◆ exception()

def grpc.Future.exception (   self,
  timeout = None 
)
Return the exception raised by the computation.

This method may return immediately or may block.

Args:
  timeout: The length of time in seconds to wait for the computation to
    terminate or be cancelled. If None, the call will block until the
    computations's termination.

Returns:
    The exception raised by the computation, or None if the computation
    did not raise an exception.

Raises:
  FutureTimeoutError: If a timeout value is passed and the computation
    does not terminate within the allotted time.
  FutureCancelledError: If the computation was cancelled.

Reimplemented in grpc._channel._MultiThreadedRendezvous, grpc._channel._SingleThreadedRendezvous, grpc._channel._InactiveRpcError, grpc._utilities._ChannelReadyFuture, grpc_testing._time._Future, default_value_client_interceptor._ConcreteValue, grpc._interceptor._UnaryOutcome, and grpc._interceptor._FailureOutcome.

Definition at line 145 of file src/python/grpcio/grpc/__init__.py.

◆ result()

def grpc.Future.result (   self,
  timeout = None 
)
Returns the result of the computation or raises its exception.

This method may return immediately or may block.

Args:
  timeout: The length of time in seconds to wait for the computation to
    finish or be cancelled. If None, the call will block until the
    computations's termination.

Returns:
  The return value of the computation.

Raises:
  FutureTimeoutError: If a timeout value is passed and the computation
    does not terminate within the allotted time.
  FutureCancelledError: If the computation was cancelled.
  Exception: If the computation raised an exception, this call will
    raise the same exception.

Reimplemented in grpc._channel._MultiThreadedRendezvous, grpc._channel._SingleThreadedRendezvous, grpc._channel._InactiveRpcError, grpc._utilities._ChannelReadyFuture, grpc_testing._time._Future, default_value_client_interceptor._ConcreteValue, grpc._interceptor._UnaryOutcome, and grpc._interceptor._FailureOutcome.

Definition at line 122 of file src/python/grpcio/grpc/__init__.py.

◆ running()

def grpc.Future.running (   self)
Describes whether the computation is taking place.

This method does not block.

Returns:
    Returns True if the computation is scheduled for execution or
    currently executing.

    Returns False if the computation already executed or was cancelled.

Reimplemented in grpc._channel._MultiThreadedRendezvous, grpc._channel._SingleThreadedRendezvous, grpc._channel._InactiveRpcError, grpc_testing._channel._invocation._FutureCall, grpc._interceptor._UnaryOutcome, grpc._utilities._ChannelReadyFuture, grpc._interceptor._FailureOutcome, grpc_testing._time._Future, and default_value_client_interceptor._ConcreteValue.

Definition at line 93 of file src/python/grpcio/grpc/__init__.py.

◆ traceback()

def grpc.Future.traceback (   self,
  timeout = None 
)
Access the traceback of the exception raised by the computation.

This method may return immediately or may block.

Args:
  timeout: The length of time in seconds to wait for the computation
    to terminate or be cancelled. If None, the call will block until
    the computation's termination.

Returns:
    The traceback of the exception raised by the computation, or None
    if the computation did not raise an exception.

Raises:
  FutureTimeoutError: If a timeout value is passed and the computation
    does not terminate within the allotted time.
  FutureCancelledError: If the computation was cancelled.

Reimplemented in grpc._channel._MultiThreadedRendezvous, grpc._channel._SingleThreadedRendezvous, grpc._channel._InactiveRpcError, grpc._utilities._ChannelReadyFuture, grpc_testing._time._Future, default_value_client_interceptor._ConcreteValue, grpc._interceptor._UnaryOutcome, and grpc._interceptor._FailureOutcome.

Definition at line 167 of file src/python/grpcio/grpc/__init__.py.


The documentation for this class was generated from the following file:


grpc
Author(s):
autogenerated on Fri May 16 2025 03:03:31