class documentation

Provide cross-loop access to one unary gRPC call.

All direct awaiters share the submitted call. Cancellation by one direct awaiter cancels the shared call and affects every waiter. Use asyncio.shield when one waiter's cancellation must not cancel the call.

Method __await__ Return an iterator that waits for the RPC result.
Method __init__ Initialize a cross-loop unary call.
Method add_done_callback Add a function to call when the RPC is complete.
Method cancel Request cancellation of the RPC.
Method cancelled Return whether the RPC was cancelled.
Async Method code Return the final gRPC status code.
Method debug_error_string Return cached native diagnostic details when grpc provides them.
Async Method details Return the final gRPC status details.
Method done Return whether the RPC is complete.
Async Method initial_metadata Return the initial RPC metadata.
Method time_remaining Return the remaining RPC timeout in seconds.
Async Method trailing_metadata Return the trailing RPC metadata.
Async Method wait_for_connection Wait until the native call has a connection.
Async Method _await_submitted Wait for the result and its published terminal state.
Async Method _call_result Return one value from the native call.
Async Method _capture_authoritative_terminal Finish terminal capture after native completion despite SDK close.
Async Method _capture_terminal Cache terminal metadata and status values.
Async Method _invoke Create and run the native call on the SDK event loop.
Method _mark_native_terminal Publish native call completion before the wrapper task resumes.
Async Method _public_call_result Return one call value to an external event loop.
Method _publish_prestart_cancellation Cache the standard local-cancellation status and wake waiters.
Method _publish_rpc_done Signal the public native-RPC completion boundary once.
Method _publish_terminal_ready Signal that no further authoritative terminal capture is pending.
Async Method _read_debug_error_string Read optional synchronous or asynchronous native diagnostics.
Method _submission_finished Publish terminal state when submission ends before call creation.
Instance Variable _address Undocumented
Instance Variable _address_channel Undocumented
Instance Variable _address_resolver Undocumented
Instance Variable _call Undocumented
Instance Variable _call_ready Undocumented
Instance Variable _cancel_requested Undocumented
Instance Variable _channel Undocumented
Instance Variable _compression Undocumented
Instance Variable _credentials Undocumented
Instance Variable _metadata Undocumented
Instance Variable _method Undocumented
Instance Variable _native_cancelled Undocumented
Instance Variable _native_terminal Undocumented
Instance Variable _pending_debug_result Undocumented
Instance Variable _released Undocumented
Instance Variable _request Undocumented
Instance Variable _request_serializer Undocumented
Instance Variable _response_deserializer Undocumented
Instance Variable _rpc_done Undocumented
Instance Variable _started_at Undocumented
Instance Variable _submitted Undocumented
Instance Variable _terminal Undocumented
Instance Variable _terminal_capture_closed Undocumented
Instance Variable _terminal_lock Undocumented
Instance Variable _terminal_ready Undocumented
Instance Variable _timeout Undocumented
Instance Variable _wait_for_ready Undocumented
def __await__(self) -> Generator[Any, None, Res]: (source)

Return an iterator that waits for the RPC result.

def __init__(self, channel: Channel, method: str, request: Req, request_serializer: SerializingFunction | None, response_deserializer: DeserializingFunction | None, timeout: float | None, metadata: MetadataType | None, credentials: CallCredentials | None, wait_for_ready: bool | None, compression: Compression | None, address: str | None = None, address_resolver: Callable[[], str] | None = None): (source)

Initialize a cross-loop unary call.

Mutable supported protobuf request values are copied before submission. Other custom request values are serialized immediately on the caller thread when a serializer is supplied. Metadata is copied to an independent gRPC metadata object. These snapshots prevent a caller from changing native-call inputs while the SDK loop is waiting to create the call. A custom request value without a serializer is assumed to be immutable or otherwise safe to share between threads.

Parameters
channel:ChannelSDK channel that owns the call.
method:strFully qualified gRPC method name.
request:ReqRequest value to send.
request_serializer:SerializingFunction | NoneOptional request serializer. For a custom request value, the SDK calls it synchronously on the thread that constructs the call. It must be thread-safe, loop-neutral, and return promptly.
response_deserializer:DeserializingFunction | NoneOptional response deserializer.
timeout:float | NoneOptional call timeout in seconds.
metadata:MetadataType | NoneOptional call metadata.
credentials:CallCredentials | NoneOptional call credentials.
wait_for_ready:bool | NoneOptional gRPC wait-for-ready setting.
compression:Compression | NoneOptional gRPC compression setting.
address:str | NoneResolved transport address. Use None to resolve the address from method.
address_resolver:Callable[[], str] | NoneOptional SDK-loop callback that resolves a deferred transport address when the native call starts.
def add_done_callback(self, callback: Callable[[Any], None]): (source)

Add a function to call when the RPC is complete.

The callback is scheduled asynchronously on the event loop active at registration. If no loop is active, it is scheduled on the SDK loop.

Parameters
callback:Callable[[Any], None]Function that receives this call.
def cancel(self) -> bool: (source)

Request cancellation of the RPC.

The method rejects cancellation after the native RPC ends. This rule also applies while the wrapper copies terminal metadata on the SDK loop.

Returns
boolTrue if the active submission accepted cancellation.
def cancelled(self) -> bool: (source)

Return whether the RPC was cancelled.

async def code(self) -> Any: (source)

Return the final gRPC status code.

def debug_error_string(self) -> str: (source)

Return cached native diagnostic details when grpc provides them.

Async gRPC call objects do not currently define this method, while grpc.aio.AioRpcError does. The cross-loop wrapper exposes the diagnostic for compatibility with callers that inspect both shapes.

Returns
strNative debug details after a failed call, or an empty string.
async def details(self) -> Any: (source)

Return the final gRPC status details.

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

Return whether the RPC is complete.

async def initial_metadata(self) -> Any: (source)

Return the initial RPC metadata.

def time_remaining(self) -> float | None: (source)

Return the remaining RPC timeout in seconds.

async def trailing_metadata(self) -> Any: (source)

Return the trailing RPC metadata.

async def wait_for_connection(self): (source)

Wait until the native call has a connection.

If channel close rejects a late accessor submission, wait for the authoritative call owner. Successful completion proves that a connection existed; its native error is otherwise propagated.

async def _await_submitted(self) -> Res: (source)

Wait for the result and its published terminal state.

If an external asyncio task is canceled, its shield wrapper is canceled first. The explicit call to cancel then sends the cancellation to an active native RPC. The method rejects cancellation after the native result or error becomes final.

If the SDK cannot start a task, the submitted future can complete before its completion callback publishes the call state. The terminal wait keeps done and the result accessors consistent when this method returns or raises that error.

Returns
ResNative RPC result.
async def _call_result(self, method: str) -> Any: (source)

Return one value from the native call.

Parameters
method:strName of the native call method to run.
Returns
AnyResult of the named method.
async def _capture_authoritative_terminal(self, call: UnaryUnaryCall[Req, Res]): (source)

Finish terminal capture after native completion despite SDK close.

Runtime shutdown cancels ordinary submissions directly. After the native call ends, that cancellation must not replace its result or error. A shielded child task copies the metadata. This submission waits for the child task before it finishes.

Parameters
call:UnaryUnaryCall[Req, Res]Authoritatively completed native call.
async def _capture_terminal(self, call: UnaryUnaryCall[Req, Res]): (source)

Cache terminal metadata and status values.

Parameters
call:UnaryUnaryCall[Req, Res]Completed or failed native call.
async def _invoke(self) -> Res: (source)

Create and run the native call on the SDK event loop.

def _mark_native_terminal(self, completed: object): (source)

Publish native call completion before the wrapper task resumes.

async def _public_call_result(self, method: str) -> Any: (source)

Return one call value to an external event loop.

Parameters
method:strName of the native call method to run.
Returns
AnyResult of the named method.
def _publish_prestart_cancellation(self): (source)

Cache the standard local-cancellation status and wake waiters.

def _publish_rpc_done(self): (source)

Signal the public native-RPC completion boundary once.

def _publish_terminal_ready(self): (source)

Signal that no further authoritative terminal capture is pending.

async def _read_debug_error_string(self, source: object, pending: Awaitable[Any] | None = None) -> str | None: (source)

Read optional synchronous or asynchronous native diagnostics.

Diagnostic accessor failures must not replace the authoritative RPC result. A pending accessor captured by the native done callback is awaited exactly once on the SDK loop.

Parameters
source:objectNative call or error that exposes the accessor.
pending:Awaitable[Any] | NoneAwaitable already created by the native done callback.
Returns
str | NoneDebug string, or None when it is unavailable.
def _submission_finished(self, submitted: CrossLoopAwaitable[Res]): (source)

Publish terminal state when submission ends before call creation.

Cancellation or asynchronous task-creation failure can end an accepted submission before its SDK coroutine starts. No finally block can then signal the call and terminal gates.

Parameters
submitted:CrossLoopAwaitable[Res]Completed SDK submission.
_address = (source)

Undocumented

_address_channel: AddressChannel | None = (source)

Undocumented

_address_resolver = (source)

Undocumented

Undocumented

_call_ready = (source)

Undocumented

_cancel_requested: bool = (source)

Undocumented

_channel = (source)

Undocumented

_compression = (source)

Undocumented

_credentials = (source)

Undocumented

_metadata = (source)

Undocumented

Undocumented

_native_cancelled = (source)

Undocumented

_native_terminal: bool = (source)

Undocumented

_pending_debug_result: Awaitable[Any] | None = (source)

Undocumented

_released: bool = (source)

Undocumented

_request: Any = (source)

Undocumented

_request_serializer: SerializingFunction | None = (source)

Undocumented

_response_deserializer = (source)

Undocumented

Undocumented

_started_at = (source)

Undocumented

_submitted = (source)

Undocumented

_terminal: dict[str, Any] = (source)

Undocumented

_terminal_capture_closed: bool = (source)

Undocumented

_terminal_lock = (source)

Undocumented

Undocumented

_timeout = (source)

Undocumented

_wait_for_ready = (source)

Undocumented