Skip to main content

Throttling, flow controlling StreamReader for aiohttp

Project description

Throttling, flow controlling StreamReader for aiohttp

https://img.shields.io/pypi/v/aiothrottle.svg Documentation Status https://img.shields.io/pypi/pyversions/aiothrottle.svg https://img.shields.io/pypi/l/aiothrottle.svg

Requirements

License

aiothrottle is offered under the GPL v3 license.

Documentation

https://aiothrottle.readthedocs.org/

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


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)

Uploaded Source

Built Distributions

aiothrottle-0.1.1.post0-py3.4.egg (8.9 kB view hashes)

Uploaded Source

aiothrottle-0.1.1.post0-py3-none-any.whl (6.6 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page