Request helper used by generated clients.
The Request class contains one RPC invocation. It controls retries,
authorization, metadata extraction, and synchronous calls. A generated client
creates the object. Await the object to perform the RPC. Its methods supply
status metadata, synchronous calls, and configurable retries and timeouts.
Key concepts:
- Authorization loop: If a provider exists, the request authorizes before the RPC. If permitted, it authorizes again after UNAUTHENTICATED.
- Retry loop: transient errors are retried according to configured retry counts and per-retry timeouts.
The request logic is central to SDK call semantics. Make only small changes that do not affect behavior.
| Class | |
Contain an RPC invocation with retries and authorization. |
| Exception | |
Base exception for errors raised while processing a request. |
| Exception | |
Exception raised when a request is cancelled. |
| Exception | |
Exception raised when a request is already sent. |
| Exception | |
Exception raised when a request is sent without a call. |
| Constant | DEFAULT |
Default timeout including the authorization and the request itself. |
| Constant | DEFAULT |
Default per-retry timeout for requests. |
| Constant | DEFAULT |
Default timeout for requests not including authorization. |
| Type Variable | |
Error type variable. Either a protobuf/message or a custom wrapper. |
| Type Variable | |
Request type variable. Either a protobuf/message or a serializable payload. |
| Type Variable | |
Response type variable. Either a protobuf/message or a custom wrapper. |
| Type Variable | T |
Undocumented |
| Variable | log |
Undocumented |
| Function | _authorization |
Return whether an authorization budget applies to one RPC, if known. |
| Function | _snapshot |
Clone a supported message before it crosses to the SDK event loop. |
| Function | _validate |
Validate one optional public timeout value. |
Channel, auth_options: dict[ str, str]) -> bool | None:
(source)
¶
Return whether an authorization budget applies to one RPC, if known.
Authorization timeout is not a second request timeout. It limits the full authorized flow, including re-authentication and request work, but must not shorten an unauthenticated request or one that explicitly disables authorization. Built-in channels expose a caller-safe probe of the provider fixed during construction; actual authentication still runs on the SDK event loop. Legacy channels without that probe return None: callers must not guess that they are unauthenticated or impose either deadline outside their owner loop. Those channels enforce both clocks inside the request authorization and retry state machine, as before.
| Parameters | |
channel:Channel | Channel that owns the RPC. |
authdict[ | Snapshotted authorization options for the RPC. |
| Returns | |
bool | None | True when authorization applies, False when it does not, or None when only the channel's owner loop can determine it. |
Clone a supported message before it crosses to the SDK event loop.
Direct generated messages and provider protobuf messages expose CopyFrom. Legacy SDK wrappers expose their provider protobuf through __pb2_message__. Unknown loop-neutral payload types retain their historical pass-through behavior.
| Parameters | |
value:T | Request value to snapshot. |
| Returns | |
T | Independent message, or value for an unknown payload type. |
Validate one optional public timeout value.
None is the documented unlimited form. Non-finite floats do not define a portable deadline for asyncio, concurrent futures, gRPC, and monotonic arithmetic, so callers must use None instead of positive infinity. Negative finite values retain their established immediate-timeout meaning.
| Parameters | |
value:float | None | Timeout in seconds or None. |
name:str | Parameter name used in the error message. |
| Returns | |
float | None | value unchanged. |
| Raises | |
ValueError | If value is NaN or infinite. |