Tiny Limit
What is TinyLimit?
tinylimit is a python modules that limits and anti-limits the calling rate of a function 与其他的limit库所不同的是,tinylimit在实战中考虑到了这些因素:
-
提供anti-limit的方法
为了让client无视被调用函数所做出的limit限制,我们提供将调用结果保存下来,如果达到被调函数已达调用频率上线,client不是直接报错,而是直接返回最近一次的调用缓存,在某些场景下(比如获取某一日的PV),读取缓存数据并不会令程序逻辑紊乱,却避免了client堵塞。这样client可以按自己的需要随意调用受限函数即可,避免client写冗长的容错逻辑
-
根据上下文施加limit
大部分的limit库是以函数为单位做limit,实际上很多第三方的API接口的限制单位为token,不同的token不会共享同一个limit额度,所以以函数名为指纹太泛,我们这里取了类实例的上下文、函数名、函数的参数列表三类信息来形成被调对象的指纹,用以应对这类场景
Programming Language
- python 2.7
- python 3.7
Install
pip install tinylimit
Quick Start
use python decorators syntax to wrap the call target
from tinylimit import AntiLimit
@AntiLimit(2,1)
def Add(a, b):
return a + b
class Foo():
@AntiLimit(2,1)
def Bar(self, a, b):
return a - b
Functions List
- AntiLimit()
Metadata
Release files for tinylimit 0.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| tinylimit-0.1.0.tar.gz | 3.1 kB | Without provenance | Details for tinylimit-0.1.0.tar.gz |
Release files / tinylimit-0.1.0.tar.gz
| Download URL | tinylimit-0.1.0.tar.gz |
|---|---|
| Size | 3.1 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
cdb0fe1af12006dffd0a655557d67cfcc9343ae2b2815e710c5c2f7976ad79fa
|
|
BLAKE2b-256 checksum How to use checksums |
0c1dba311a130ba74983f826f384f1aa564a2087f1bde6a7a3258474ee1d8514
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/1.15.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/44.0.0 requests-toolbelt/0.9.1 tqdm/4.42.1 CPython/2.7.15
|
Security for tinylimit 0.1.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.