class Receiver(ParentReceiver): (source)
Constructor: Receiver(parent, max_retries)
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 | |
| parent | The Bearer instance that performs background token
fetch and renewal. |
| max | Maximum 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 |
Decide whether a failed fetch should be retried. |
| Async Method | _fetch |
Fetch a token by delegating to the parent bearer. |
| Instance Variable | _max |
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. |
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:Exception | The exception raised by the failed fetch (unused but provided for API compatibility). |
options:dict[ | Optional mapping of request options that may
contain an override for OPTION_MAX_RETRIES or the
synchronous renewal flag. |
| Returns | |
bool | True when another retry should be attempted,
False otherwise. |
float | None = None, options: dict[ str, str] | None = None) -> Token:
(source)
¶
nebius.aio.token.token.Receiver._fetchFetch 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 | None | Optional timeout in seconds forwarded to the parent's fetch implementation. |
options:dict[ | Optional request-specific options forwarded to the parent bearer. |
| Returns | |
Token | The fetched Token. |