Throttling, flow controlling StreamReader for aiohttp
Project description
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 functools
import aiohttp
import aiothrottle
# setup the rate limit to 200 KB/s
aiothrottle.limit_rate(200 * 1024)
# download a large file without blocking bandwidth
response = aiohttp.request("GET", "http://example.com/largefile.zip")
with open("largefile.zip", "wb") as file:
read_next = True
while read_next:
# read 1 MB chunks
chunk = response.content.read(2**20)
file.write(chunk)
read_next = len(chunk) != 0
response.close()
# unset the rate limit
aiothrottle.unlimit_rate()
TODO
Unit tests
Upload rate limiting class
General socket limiting class
CHANGES
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
aiothrottle-0.1.1.post0.zip
(8.1 kB
view hashes)
Built Distributions
Close
Hashes for aiothrottle-0.1.1.post0-py3.4.egg
Algorithm | Hash digest | |
---|---|---|
SHA256 | 725d0e8039af86b52b20daf14a742cea37a0a172631e881b0746b5c6d1b727a7 |
|
MD5 | efc919dd04907dca9218beb543e48063 |
|
BLAKE2b-256 | e831698cc09669bf2ebe4b308d0ea895176fc8e425f658f87f8c646ad6c9e9e6 |
Close
Hashes for aiothrottle-0.1.1.post0-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 89556ea61edac8e24a46165f699768683edfa30006e83387dee359eff2d097b9 |
|
MD5 | b9c03cb41bc49b78e63f4330c949c3d4 |
|
BLAKE2b-256 | 66edbf8d119f9db39745227cf685d4383b46d7937bfe4b6a7cb8229f807800a6 |