A ratelimiting Session adapter for requests.
Project description
requests-ratelimit-adapter
A ratelimiting Session adapter for requests.
- Free software: MIT license
- Documentation: https://requests-ratelimit-adapter.readthedocs.io.
Example
>>> from requests_ratelimit_adapter import RateLimitAdapter
>>> from requests.adapters import HTTPAdapter
>>> import requests
>>> import time
>>> # Create an HTTP adapter.
>>> http = HTTPAdapter()
>>> # Create a rate limiting adapter
>>> rate_limiter = RateLimitAdapter(adapter=http, calls=1, period=1)
>>> s = requests.Session()
>>> s.mount("https://", rate_limiter)
>>> # This first request will start the period.
>>> r = s.get("https://httpbin.org/get")
>>> r.raise_for_status()
>>> time1 = time.time()
>>> # This second request will wait 1 second before executing.
>>> r2 = s.get("https://httpbin.org/get")
>>> r2.raise_for_status()
>>> time2 = time.time()
>>> # For this example, verify the timestamps are more than a second apart.
>>> assert time2 >= time1 + 1
Credits
This package was created with Cookiecutter and the cmeister2/cookiecutter-pypackage project template.
Changelog
All notable changes to this project will be documented in this file.
The format is based on Keep a Changelog, and this project adheres to Semantic Versioning.
Unreleased
Changed
0.1.2 - 2018-12-24
Changed
- Use the correct travis password for deploying to PyPI.
0.1.1 - 2018-12-24
Added
- Add travis password for deploying to PyPI.
0.1.0 - 2018-12-24
Added
- Initial commit of code.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Close
Hashes for requests_ratelimit_adapter-0.1.2.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | 16c666c94f2072b73b1c239b4d1b51b49de3315cf25799ed47bbd2f957ffada0 |
|
MD5 | 7047208f571e869c9bb9a644d09e7702 |
|
BLAKE2b-256 | 9aa55d71614994162e18b4c85868050171190a0bad6020a974176df98220cf63 |
Close
Hashes for requests_ratelimit_adapter-0.1.2-py2.py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | caba0661588db6e6198ed96c701b07714d52a3d9c12d8978164a7d9e02c80b9b |
|
MD5 | 429b4d63b331d4604134ff66d3dc4878 |
|
BLAKE2b-256 | 82235901bb20bdc02d922a34584f236f3d3efe45d751ecaee10ffaa3dffcdcf0 |