build.utils.misc.throttling   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 33
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
wmc 2
eloc 8
dl 0
loc 33
rs 10
c 0
b 0
f 0

1 Function

Rating   Name   Duplication   Size   Complexity  
A rate_limit() 0 18 2
1
# -*- coding: utf-8 -*-
2
3
4
"""
5
6
7
    Created on 10.09.2021
8
9
    @author: Nikita
10
11
12
"""
13
14
15
def rate_limit(limit: int, key=None):
16
17
    """
18
19
    Decorator for configuring rate limit and key in different functions.
20
21
    """
22
23
    def decorator(func):
24
25
        setattr(func, 'throttling_rate_limit', limit)
26
27
        if key:
28
            setattr(func, 'throttling_key', key)
29
30
        return func
31
32
    return decorator
33