Skip to content

panda73111/aiothrottle

Repository files navigation

aiothrottle

Throttling, flow controlling StreamReader for aiohttp

Package Version

Build Status

Coverage Status

Documentation Status

Python Version

GPLv3

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

About

[paused] Throttling, flow controlling StreamReader for aiohttp

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages