Skip to main content

No project description provided

Project description

A Python library for API throttling.

Installation

To install the latest release on PyPi, simply run:

pip install throttle_bag

Or to install the latest development version, run:

git clone https://github.com/xinhuang/throttle-bag.git
cd throttle-bag
python setup.py install

Quick Tutorial

>>> from throttle_bag import Throttle
>>> import requests
>>>
>>> r = Throttle(requests, seconds=10, times=20)
>>> while True:
>>>     r.get('http://www.google.com')

API Reference

Throttle(throttled_object, seconds, times=1, aio=False, loop=None)

Create a instance of Throttle to throttle invocations to all methods of throttled_object, according to frequence specified.

Args:
  • throttled_object: The object to be throttled.
  • seconds: Specify throttling interval in seconds.
  • times: Specify how many invocations can be made in given interval.
  • aio: Whether use asyncio.sleep() instead of time.sleep().
  • aio: The EventLoop if using asyncio. By default it is asyncio.get_event_loop().
  • delay: Custom delay function. For synchronized, it is def delay(seconds); for asynchronized, it is async def delay(seconds).

Licensing

This project is released under the terms of the MIT Open Source License. View LICENSE.txt for more information.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Filename, size & hash SHA256 hash help File type Python version Upload date
throttle_bag-0.3-py3-none-any.whl (6.5 kB) Copy SHA256 hash SHA256 Wheel 3.6

Supported by

Elastic Elastic Search Pingdom Pingdom Monitoring Google Google BigQuery Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN SignalFx SignalFx Supporter DigiCert DigiCert EV certificate StatusPage StatusPage Status page