class documentation

Per-request receiver that delegates fetching to the parent renewable bearer while accounting for retry attempts.

The receiver tracks the number of fetch attempts for a single request. On transient failures it can instruct the parent bearer to schedule a background renewal (unless a synchronous renewal was requested via options).

Example

receiver = bearer.receiver()
token = await receiver.fetch(timeout=5)
Parameters
parentThe Bearer instance that performs background token fetch and renewal.
max_retriesMaximum number of automatic retry attempts this receiver will allow before giving up.
Method __init__ Create a receiver bound to the given renewable bearer.
Method can_retry Decide whether a failed fetch should be retried.
Async Method _fetch Fetch a token by delegating to the parent bearer.
Instance Variable _max_retries Undocumented
Instance Variable _parent Undocumented
Instance Variable _trial Undocumented

Inherited from Receiver:

Async Method fetch Fetch a token and record it as the latest value.
Property latest Return the latest fetched token or None.
Instance Variable _latest The most recently fetched token, or None if no token has been fetched yet. Implementations may update this to support inspection or caching by callers.
def __init__(self, parent: Bearer, max_retries: int = 2): (source)

Create a receiver bound to the given renewable bearer.

def can_retry(self, err: Exception, options: dict[str, str] | None = None) -> bool: (source)

Decide whether a failed fetch should be retried.

The decision is based on the configured maximum retry count and an optional OPTION_RENEW_SYNCHRONOUS option which disables background renewal triggering.

Parameters
err:ExceptionThe exception raised by the failed fetch (unused but provided for API compatibility).
options:dict[str, str] | NoneOptional mapping of request options that may contain an override for OPTION_MAX_RETRIES or the synchronous renewal flag.
Returns
boolTrue when another retry should be attempted, False otherwise.
async def _fetch(self, timeout: float | None = None, options: dict[str, str] | None = None) -> Token: (source)

Fetch a token by delegating to the parent bearer.

This method increments the internal trial counter which is used by can_retry to decide whether further retries are permitted.

Parameters
timeout:float | NoneOptional timeout in seconds forwarded to the parent's fetch implementation.
options:dict[str, str] | NoneOptional request-specific options forwarded to the parent bearer.
Returns
TokenThe fetched Token.
_max_retries = (source)

Undocumented

Undocumented

Undocumented