class documentation

Simple container for a gRPC channel and its resolved address.

Parameters
channelThe underlying grpc.aio.Channel instance.
addressThe resolved address string (for example 'host:port') that was used to create the channel.
event_loopEvent loop that owns channel. This is optional for compatibility with callers constructing an AddressChannel directly. When omitted, ownership is inferred from the running or current loop. Callers wrapping a channel created elsewhere should pass its owner loop explicitly because this inference is only best effort.
Method __init__ Initialize an AddressChannel instance.
Instance Variable address Resolved address string used to create the channel.
Instance Variable channel The underlying gRPC channel instance.
Instance Variable event_loop Event loop that owns the underlying gRPC channel.
Method _ensure_close_state Initialize lifecycle state for legacy subclasses that skipped init.
Method _is_closed_by_sdk Return whether SDK lifecycle management closed this transport.
Method _is_retired_by_sdk Return whether SDK lifecycle management reserved this transport.
Method _mark_closed_by_sdk Record that SDK lifecycle management closed this transport.
Method _new_lease Create a fresh wrapper for another lease of this transport.
Method _retire_by_sdk Atomically reserve this transport for SDK-managed closure.
Class Variable _legacy_close_state_init_lock Undocumented
Instance Variable _close_state_lock Undocumented
Instance Variable _closed_by_sdk Undocumented
Instance Variable _retired_by_sdk Undocumented
def __init__(self, channel: GRPCChannel, address: str, event_loop: AbstractEventLoop | None = None): (source)

Initialize an AddressChannel instance.

address: str = (source)

Resolved address string used to create the channel.

The underlying gRPC channel instance.

Event loop that owns the underlying gRPC channel.

def _ensure_close_state(self) -> Lock: (source)

Initialize lifecycle state for legacy subclasses that skipped init.

Older custom wrappers sometimes override __init__ without calling this base class. The class lock makes lazy initialization atomic while preserving that compatibility.

Returns
LockPer-wrapper lock protecting the SDK-close marker.
def _is_closed_by_sdk(self) -> bool: (source)

Return whether SDK lifecycle management closed this transport.

def _is_retired_by_sdk(self) -> bool: (source)

Return whether SDK lifecycle management reserved this transport.

def _mark_closed_by_sdk(self): (source)

Record that SDK lifecycle management closed this transport.

def _new_lease(self) -> AddressChannel: (source)

Create a fresh wrapper for another lease of this transport.

A fresh wrapper prevents an old holder from releasing a later lease. Custom wrappers can override this method when they must preserve additional wrapper state.

Returns
AddressChannelNew wrapper for the same native channel and owner loop.
def _retire_by_sdk(self) -> bool: (source)

Atomically reserve this transport for SDK-managed closure.

Retirement is permanent even when an owner loop stops before the native close can finish. A transport whose close was requested must never re-enter a pool while that close is pending or after its owner loop becomes available again.

Returns
boolTrue only for the caller that changed the transport from reusable to retired. Later close attempts return False.
_legacy_close_state_init_lock = (source)

Undocumented

_close_state_lock: Lock = (source)

Undocumented

_closed_by_sdk: bool = (source)

Undocumented

_retired_by_sdk: bool = (source)

Undocumented