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 details)

Uploaded Source

Built Distributions

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

Uploaded Source

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

Uploaded Python 3

File details

Details for the file aiothrottle-0.1.1.post0.zip.

File metadata

File hashes

Hashes for aiothrottle-0.1.1.post0.zip
Algorithm Hash digest
SHA256 1556f1cafc576fd106e12ec21e5f1470ad3eca5b5d840dccbbe2366d85a8cbbb
MD5 974a5513edca3efb9afcb74a73b7fb5a
BLAKE2b-256 027fffd88aa2e24cabb80eddbe643163c380cf851596a95522c3c0be9ab6f1c0

See more details on using hashes here.

File details

Details for the file aiothrottle-0.1.1.post0-py3.4.egg.

File metadata

File hashes

Hashes for aiothrottle-0.1.1.post0-py3.4.egg
Algorithm Hash digest
SHA256 725d0e8039af86b52b20daf14a742cea37a0a172631e881b0746b5c6d1b727a7
MD5 efc919dd04907dca9218beb543e48063
BLAKE2b-256 e831698cc09669bf2ebe4b308d0ea895176fc8e425f658f87f8c646ad6c9e9e6

See more details on using hashes here.

File details

Details for the file aiothrottle-0.1.1.post0-py3-none-any.whl.

File metadata

File hashes

Hashes for aiothrottle-0.1.1.post0-py3-none-any.whl
Algorithm Hash digest
SHA256 89556ea61edac8e24a46165f699768683edfa30006e83387dee359eff2d097b9
MD5 b9c03cb41bc49b78e63f4330c949c3d4
BLAKE2b-256 66edbf8d119f9db39745227cf685d4383b46d7937bfe4b6a7cb8229f807800a6

See more details on using hashes here.

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