没有项目描述
throttle-bag的Python项目详细描述
用于API节流的Python库
安装
要在PyPi上安装最新版本, 只需运行:
pip install throttle_bag
或者要安装最新的开发版本,请运行:
git clone https://github.com/xinhuang/throttle-bag.git cd throttle-bag python setup.py install
快速教程
>>> fromthrottle_bagimportThrottle>>> importrequests>>> >>> r=Throttle(requests,seconds=10,times=20)>>> whileTrue:>>> r.get('http://www.google.com')
API参考
- Throttle(throttled_object, seconds, times=1, aio=False, loop=None)
根据频率创建Throttle的实例,以限制对所有受限制对象方法的调用 明确规定。
Args: - ^{tt3}$: The object to be throttled.
- ^{tt4}$: Specify throttling interval in seconds.
- ^{tt5}$: Specify how many invocations can be made in given interval.
- ^{tt6}$: Whether use ^{tt7}$ instead of ^{tt8}$.
- ^{tt6}$: The ^{tt10}$ if using asyncio. By default it is ^{tt11}$.
- ^{tt12}$: Custom delay function. For synchronized, it is ^{tt13}$; for asynchronized, it is ^{tt14}$.
许可
这个项目是根据麻省理工学院开放源码许可证的条款发布的。意见 license.txt了解更多信息。