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

Public Member Functions

def __aenter__ (self)
 
def __aexit__ (self, exc_type, exc_val, exc_tb)
 
None channel_ready (self)
 
def close (self, Optional[float] grace=None)
 
grpc.ChannelConnectivity get_state (self, bool try_to_connect=False)
 
StreamStreamMultiCallable stream_stream (self, str method, Optional[SerializingFunction] request_serializer=None, Optional[DeserializingFunction] response_deserializer=None)
 
StreamUnaryMultiCallable stream_unary (self, str method, Optional[SerializingFunction] request_serializer=None, Optional[DeserializingFunction] response_deserializer=None)
 
UnaryStreamMultiCallable unary_stream (self, str method, Optional[SerializingFunction] request_serializer=None, Optional[DeserializingFunction] response_deserializer=None)
 
UnaryUnaryMultiCallable unary_unary (self, str method, Optional[SerializingFunction] request_serializer=None, Optional[DeserializingFunction] response_deserializer=None)
 
None wait_for_state_change (self, grpc.ChannelConnectivity last_observed_state)
 

Detailed Description

Enables asynchronous RPC invocation as a client.

Channel objects implement the Asynchronous Context Manager (aka. async
with) type, although they are not supportted to be entered and exited
multiple times.

Definition at line 184 of file _base_channel.py.

Member Function Documentation

◆ __aenter__()

def grpc.aio._base_channel.Channel.__aenter__ (   self)
Enables asynchronous RPC invocation as a client.

Channel objects implement the Asynchronous Context Manager (aka. async
with) type, although they are not supportted to be entered and exited
multiple times.
Starts an asynchronous context manager.

Returns:
  Channel the channel that was instantiated.

Reimplemented in grpc.aio._channel.Channel.

Definition at line 193 of file _base_channel.py.

◆ __aexit__()

def grpc.aio._base_channel.Channel.__aexit__ (   self,
  exc_type,
  exc_val,
  exc_tb 
)
Finishes the asynchronous context manager by closing the channel.

Still active RPCs will be cancelled.

Reimplemented in grpc.aio._channel.Channel.

Definition at line 201 of file _base_channel.py.

◆ channel_ready()

None grpc.aio._base_channel.Channel.channel_ready (   self)
Creates a coroutine that blocks until the Channel is READY.

Reimplemented in grpc.aio._channel.Channel.

Definition at line 267 of file _base_channel.py.

◆ close()

def grpc.aio._base_channel.Channel.close (   self,
Optional[float]   grace = None 
)
Closes this Channel and releases all resources held by it.

This method immediately stops the channel from executing new RPCs in
all cases.

If a grace period is specified, this method wait until all active
RPCs are finshed, once the grace period is reached the ones that haven't
been terminated are cancelled. If a grace period is not specified
(by passing None for grace), all existing RPCs are cancelled immediately.

This method is idempotent.

Reimplemented in grpc.aio._channel.Channel.

Definition at line 208 of file _base_channel.py.

◆ get_state()

grpc.ChannelConnectivity grpc.aio._base_channel.Channel.get_state (   self,
bool   try_to_connect = False 
)
Checks the connectivity state of a channel.

This is an EXPERIMENTAL API.

If the channel reaches a stable connectivity state, it is guaranteed
that the return value of this function will eventually converge to that
state.

Args:
  try_to_connect: a bool indicate whether the Channel should try to
    connect to peer or not.

Returns: A ChannelConnectivity object.

Reimplemented in grpc.aio._channel.Channel.

Definition at line 223 of file _base_channel.py.

◆ stream_stream()

StreamStreamMultiCallable grpc.aio._base_channel.Channel.stream_stream (   self,
str  method,
Optional[SerializingFunction]   request_serializer = None,
Optional[DeserializingFunction]   response_deserializer = None 
)
Creates a StreamStreamMultiCallable for a stream-stream method.

Args:
  method: The name of the RPC method.
  request_serializer: Optional :term:`serializer` for serializing the request
    message. Request goes unserialized in case None is passed.
  response_deserializer: Optional :term:`deserializer` for deserializing the
    response message. Response goes undeserialized in case None
    is passed.

Returns:
  A StreamStreamMultiCallable value for the named stream-stream method.

Reimplemented in grpc.aio._channel.Channel.

Definition at line 334 of file _base_channel.py.

◆ stream_unary()

StreamUnaryMultiCallable grpc.aio._base_channel.Channel.stream_unary (   self,
str  method,
Optional[SerializingFunction]   request_serializer = None,
Optional[DeserializingFunction]   response_deserializer = None 
)
Creates a StreamUnaryMultiCallable for a stream-unary method.

Args:
  method: The name of the RPC method.
  request_serializer: Optional :term:`serializer` for serializing the request
    message. Request goes unserialized in case None is passed.
  response_deserializer: Optional :term:`deserializer` for deserializing the
    response message. Response goes undeserialized in case None
    is passed.

Returns:
  A StreamUnaryMultiCallable value for the named stream-unary method.

Reimplemented in grpc.aio._channel.Channel.

Definition at line 313 of file _base_channel.py.

◆ unary_stream()

UnaryStreamMultiCallable grpc.aio._base_channel.Channel.unary_stream (   self,
str  method,
Optional[SerializingFunction]   request_serializer = None,
Optional[DeserializingFunction]   response_deserializer = None 
)
Creates a UnaryStreamMultiCallable for a unary-stream method.

Args:
  method: The name of the RPC method.
  request_serializer: Optional :term:`serializer` for serializing the request
    message. Request goes unserialized in case None is passed.
  response_deserializer: Optional :term:`deserializer` for deserializing the
    response message. Response goes undeserialized in case None
    is passed.

Returns:
  A UnarySteramMultiCallable value for the named unary-stream method.

Reimplemented in grpc.aio._channel.Channel.

Definition at line 292 of file _base_channel.py.

◆ unary_unary()

UnaryUnaryMultiCallable grpc.aio._base_channel.Channel.unary_unary (   self,
str  method,
Optional[SerializingFunction]   request_serializer = None,
Optional[DeserializingFunction]   response_deserializer = None 
)
Creates a UnaryUnaryMultiCallable for a unary-unary method.

Args:
  method: The name of the RPC method.
  request_serializer: Optional :term:`serializer` for serializing the request
    message. Request goes unserialized in case None is passed.
  response_deserializer: Optional :term:`deserializer` for deserializing the
    response message. Response goes undeserialized in case None
    is passed.

Returns:
  A UnaryUnaryMultiCallable value for the named unary-unary method.

Reimplemented in grpc.aio._channel.Channel.

Definition at line 271 of file _base_channel.py.

◆ wait_for_state_change()

None grpc.aio._base_channel.Channel.wait_for_state_change (   self,
grpc.ChannelConnectivity  last_observed_state 
)
Waits for a change in connectivity state.

This is an EXPERIMENTAL API.

The function blocks until there is a change in the channel connectivity
state from the "last_observed_state". If the state is already
different, this function will return immediately.

There is an inherent race between the invocation of
"Channel.wait_for_state_change" and "Channel.get_state". The state can
change arbitrary many times during the race, so there is no way to
observe every state transition.

If there is a need to put a timeout for this function, please refer to
"asyncio.wait_for".

Args:
  last_observed_state: A grpc.ChannelConnectivity object representing
    the last known state.

Reimplemented in grpc.aio._channel.Channel.

Definition at line 241 of file _base_channel.py.


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


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