Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/se7entyse7en/requests-throttler
Python HTTP requests throttler
https://github.com/se7entyse7en/requests-throttler
Last synced: 8 days ago
JSON representation
Python HTTP requests throttler
- Host: GitHub
- URL: https://github.com/se7entyse7en/requests-throttler
- Owner: se7entyse7en
- License: other
- Created: 2013-12-30T16:20:30.000Z (almost 11 years ago)
- Default Branch: master
- Last Pushed: 2024-07-16T13:28:22.000Z (5 months ago)
- Last Synced: 2024-12-08T19:53:21.042Z (17 days ago)
- Language: Python
- Homepage:
- Size: 264 KB
- Stars: 30
- Watchers: 3
- Forks: 13
- Open Issues: 4
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGES.md
- License: LICENSE
Awesome Lists containing this project
README
# RequestsThrottler: HTTP requests throttler
RequestsThrottler is an Apache2 Licensed HTTP library, written in Python, and powered by futures and [Requests](https://github.com/kennethreitz/requests).
See the [full documentation](http://pythonhosted.org/RequestsThrottler).With RequestsThrottler you can easily throttle HTTP requests! After having created your throttler with a delay of your choice, you just have to:
1. Start the throttler
2. Submit your requests
3. Shutdown the throttlerHere's an example:
import requests
from requests_throttler import BaseThrottlerbt = BaseThrottler(name='base-throttler', delay=1.5)
request = requests.Request(method='GET', url='http://www.google.com')
reqs = [request for i in range(0, 5)]bt.start()
throttled_requests = bt.multi_submit(reqs)
bt.shutdown()responses = [tr.response for tr in throttled_requests]
Too hard? Then just submit your requests inside a with statement! Here's an example:
import requests
from requests_throttler import BaseThrottlerwith BaseThrottler(name='base-throttler', delay=1.5) as bt:
request = requests.Request(method='GET', url='http://www.google.com')
reqs = [request for i in range(0, 5)]
throttled_requests = bt.multi_submit(reqs)responses = [tr.response for tr in throttled_requests]
## Installation
Use `pip` to install RequestsThrottler:
$ pip install RequestsThrottler
## Features
- `BaseThrottler` a simple throttler with a fixed amount of delay