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.
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
kbps = 200
partial = functools.partial(
aiothrottle.ThrottledStreamReader, rate_limit=kbps * 1024)
aiohttp.client_reqrep.ClientResponse.flow_control_class = partial
# 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
aiohttp.client_reqrep.ClientResponse.flow_control_class = (
aiohttp.streams.FlowControlStreamReader)
CHANGES
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.0.zip
(5.7 kB
view details)
Built Distribution
aiothrottle-0.1.0-py3.4.egg
(6.7 kB
view details)
File details
Details for the file aiothrottle-0.1.0.zip
.
File metadata
- Download URL: aiothrottle-0.1.0.zip
- Upload date:
- Size: 5.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 8db23c21c971420ec6a63b135b07d814f3a8ce25797716428b58d13b90c20b2e |
|
MD5 | e20c70f6997020662d4c3954567ac36d |
|
BLAKE2b-256 | 5a37c4f2db407cbafd99660e7daab8554265f5ec78871bce84f1eb213c8c5d79 |
File details
Details for the file aiothrottle-0.1.0-py3.4.egg
.
File metadata
- Download URL: aiothrottle-0.1.0-py3.4.egg
- Upload date:
- Size: 6.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | e89362f9ed66a42138c2c1085bc5de90fdf72e71b55641191fbe75a81af2d7a9 |
|
MD5 | 24ae853876168563602999552c0362cf |
|
BLAKE2b-256 | 8645176a787444ddab970c15af4a8ca9f6dba7471a197ea11a43ed4ebb66142c |