Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
self.rate = rate
self.per = per
self.burst = burst
self._default_bucket = TokenBucket(rate, per, burst)
self._substr_buckets = None
self._auto_buckets = None
if 'match' in kwargs:
if kwargs['match'] == 'auto':
self._auto_buckets = defaultdict(partial(TokenBucket, rate, per, burst))
else:
self._substr_buckets = {}
for s in kwargs['match']:
# Create a new token bucket for each substring
self._substr_buckets[s] = TokenBucket(rate, per, burst)
:param kwargs:
Additional config options that can be passed to the filter.
"""
super(RateLimitingFilter, self).__init__()
self.rate = rate
self.per = per
self.burst = burst
self._default_bucket = TokenBucket(rate, per, burst)
self._substr_buckets = None
self._auto_buckets = None
if 'match' in kwargs:
if kwargs['match'] == 'auto':
self._auto_buckets = defaultdict(partial(TokenBucket, rate, per, burst))
else:
self._substr_buckets = {}
for s in kwargs['match']:
# Create a new token bucket for each substring
self._substr_buckets[s] = TokenBucket(rate, per, burst)
:param rate:
The number of records to restrict to, per the specified time interval. Default 1.
:param per:
The number of seconds during which 'rate' records may be sent. Default 30.
:param burst:
The maximum number of records that can be sent before rate limiting kicks in.
:param kwargs:
Additional config options that can be passed to the filter.
"""
super(RateLimitingFilter, self).__init__()
self.rate = rate
self.per = per
self.burst = burst
self._default_bucket = TokenBucket(rate, per, burst)
self._substr_buckets = None
self._auto_buckets = None
if 'match' in kwargs:
if kwargs['match'] == 'auto':
self._auto_buckets = defaultdict(partial(TokenBucket, rate, per, burst))
else:
self._substr_buckets = {}
for s in kwargs['match']:
# Create a new token bucket for each substring
self._substr_buckets[s] = TokenBucket(rate, per, burst)