pyrate_limiter.extras.httpx_limiter module¶
- class pyrate_limiter.extras.httpx_limiter.AsyncRateLimiterTransport(limiter, **kwargs)¶
Bases:
AsyncHTTPTransportAn asynchronous HTTPX transport that enforces a rate limit via a provided
Limiter.All requests share the same limiter item key, so the same rate limit is applied globally across requests.
- __init__(limiter, **kwargs)¶
Initialize the transport.
- Parameters:
limiter (
Limiter) – Limiter used to control request rate.**kwargs – Additional keyword arguments passed to
httpx.AsyncHTTPTransport.
- async handle_async_request(request, **kwargs)¶
Handle an asynchronous HTTP request after acquiring from the limiter.
The limiter is polled until a permit is acquired; all requests share the same limiter key.
- Parameters:
request (
httpx.Request) – The request to send.**kwargs – Forwarded to
httpx.AsyncHTTPTransport.handle_async_request().
- Returns:
The HTTP response.
- Return type:
httpx.Response
- class pyrate_limiter.extras.httpx_limiter.RateLimiterTransport(limiter, **kwargs)¶
Bases:
HTTPTransportA synchronous HTTPX transport that enforces a rate limit via a provided
Limiter.All requests share the same limiter item key, so the same rate limit is applied globally across requests.
- __init__(limiter, **kwargs)¶
Initialize the transport.
- Parameters:
limiter (
Limiter) – Limiter used to control request rate.**kwargs – Additional keyword arguments passed to
httpx.HTTPTransport.
- handle_request(request, **kwargs)¶
Handle a synchronous HTTP request after acquiring from the limiter.
The limiter is polled until a permit is acquired; all requests share the same limiter key.
- Parameters:
request (
httpx.Request) – The request to send.**kwargs – Forwarded to
httpx.HTTPTransport.handle_request().
- Returns:
The HTTP response.
- Return type:
httpx.Response