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

Public Member Functions

def __aenter__ (self)
 
def __aexit__ (self, exc_type, exc_val, exc_tb)
 
def __del__ (self)
 
def __init__ (self, str target, ChannelArgumentType options, Optional[grpc.ChannelCredentials] credentials, Optional[grpc.Compression] compression, Optional[Sequence[ClientInterceptor]] interceptors)
 
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)
 

Private Member Functions

def _close (self, grace)
 

Private Attributes

 _channel
 
 _loop
 
 _stream_stream_interceptors
 
 _stream_unary_interceptors
 
 _unary_stream_interceptors
 
 _unary_unary_interceptors
 

Detailed Description

Definition at line 244 of file grpc/aio/_channel.py.

Constructor & Destructor Documentation

◆ __init__()

def grpc.aio._channel.Channel.__init__ (   self,
str  target,
ChannelArgumentType  options,
Optional[grpc.ChannelCredentials credentials,
Optional[grpc.Compression compression,
Optional[Sequence[ClientInterceptor]]  interceptors 
)
Constructor.

Args:
  target: The target to which to connect.
  options: Configuration options for the channel.
  credentials: A cygrpc.ChannelCredentials or None.
  compression: An optional value indicating the compression method to be
    used over the lifetime of the channel.
  interceptors: An optional list of interceptors that would be used for
    intercepting any RPC executed with that channel.

Definition at line 252 of file grpc/aio/_channel.py.

◆ __del__()

def grpc.aio._channel.Channel.__del__ (   self)

Definition at line 376 of file grpc/aio/_channel.py.

Member Function Documentation

◆ __aenter__()

def grpc.aio._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 from grpc.aio._base_channel.Channel.

Definition at line 296 of file grpc/aio/_channel.py.

◆ __aexit__()

def grpc.aio._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 from grpc.aio._base_channel.Channel.

Definition at line 299 of file grpc/aio/_channel.py.

◆ _close()

def grpc.aio._channel.Channel._close (   self,
  grace 
)
private

Definition at line 302 of file grpc/aio/_channel.py.

◆ channel_ready()

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

Reimplemented from grpc.aio._base_channel.Channel.

Definition at line 393 of file grpc/aio/_channel.py.

◆ close()

def grpc.aio._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 from grpc.aio._base_channel.Channel.

Definition at line 373 of file grpc/aio/_channel.py.

◆ get_state()

grpc.ChannelConnectivity grpc.aio._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 from grpc.aio._base_channel.Channel.

Definition at line 381 of file grpc/aio/_channel.py.

◆ stream_stream()

StreamStreamMultiCallable grpc.aio._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 from grpc.aio._base_channel.Channel.

Definition at line 435 of file grpc/aio/_channel.py.

◆ stream_unary()

StreamUnaryMultiCallable grpc.aio._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 from grpc.aio._base_channel.Channel.

Definition at line 423 of file grpc/aio/_channel.py.

◆ unary_stream()

UnaryStreamMultiCallable grpc.aio._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 from grpc.aio._base_channel.Channel.

Definition at line 411 of file grpc/aio/_channel.py.

◆ unary_unary()

UnaryUnaryMultiCallable grpc.aio._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 from grpc.aio._base_channel.Channel.

Definition at line 399 of file grpc/aio/_channel.py.

◆ wait_for_state_change()

None grpc.aio._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 from grpc.aio._base_channel.Channel.

Definition at line 386 of file grpc/aio/_channel.py.

Member Data Documentation

◆ _channel

grpc.aio._channel.Channel._channel
private

Definition at line 288 of file grpc/aio/_channel.py.

◆ _loop

grpc.aio._channel.Channel._loop
private

Definition at line 287 of file grpc/aio/_channel.py.

◆ _stream_stream_interceptors

grpc.aio._channel.Channel._stream_stream_interceptors
private

Definition at line 267 of file grpc/aio/_channel.py.

◆ _stream_unary_interceptors

grpc.aio._channel.Channel._stream_unary_interceptors
private

Definition at line 266 of file grpc/aio/_channel.py.

◆ _unary_stream_interceptors

grpc.aio._channel.Channel._unary_stream_interceptors
private

Definition at line 265 of file grpc/aio/_channel.py.

◆ _unary_unary_interceptors

grpc.aio._channel.Channel._unary_unary_interceptors
private

Definition at line 264 of file grpc/aio/_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