test_ratelimits.py 文件源码

python
阅读 27 收藏 0 点赞 0 评论 0

项目:merakicommons 作者: meraki-analytics 项目源码 文件源码
def test_window_decorator_timing():
    from time import monotonic

    limiter = FixedWindowRateLimiter(SECONDS, PERMITS)

    @limiter.limit
    def call():
        return monotonic()

    times = []
    for _ in range(VALUE_COUNT):
        times.append(call())

    start_indexes = [i for i in range(VALUE_COUNT) if i % PERMITS == 0]

    last = -SECONDS
    for index in start_indexes:
        assert times[index] - last >= SECONDS - EPSILON
        last = times[index]
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号