Throttling, flow controlling StreamReader for aiohttp
Project description
aiothrottle
Throttling, flow controlling StreamReader for aiohttp
Requirements
Python >= 3.3
License
aiothrottle is offered under the GPL v3 license.
Documentation
Source code
The latest developer version is available in a github repository: https://github.com/panda73111/aiothrottle
Usage
import asyncio
import aiohttp
import aiothrottle
@asyncio.coroutine
def load_file(url):
response = yield from aiohttp.request("GET", url)
data = yield from response.read()
with open("largefile.zip", "wb") as file:
file.write(data)
response.close()
# setup the rate limit to 200 KB/s
aiothrottle.limit_rate(200 * 1024)
# download a large file without blocking bandwidth
loop = asyncio.get_event_loop()
loop.run_until_complete(load_file(
"http://example.com/largefile.zip"))
# unset the rate limit
aiothrottle.unlimit_rate()
TODO
Upload rate limiting class
General socket limiting class
CHANGES
0.1.2 (08-08-2015)
Fixed resuming transport too often
Added ‘rate_limit’ and ‘throttling’ properties
Fixed buffer limit control
0.1.1 (08-02-2015)
Added limit_rate() and unlimit_rate() globally and response-wise
Raising ValueError on invalid rate limit
Cancelling _check_handle in Throttle’s destructor
0.1.0 (08-01-2015)
Initial release with basic throttling functionality
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 Distributions
Hashes for aiothrottle-0.1.2-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | d7e952d490f3994226cd845c6faac9cd75a342be180bc6eb95a3f3259e92ef6d |
|
MD5 | 6deeb306eab281565ee0ef386d8e8b4b |
|
BLAKE2b-256 | d69f57a019f758470e78922fe39b4c7065b1aa12a1e7de7521b1d45ae8942dd7 |