Skip to content

Commit c7f29b1

Browse files
committed
Clean the PR
1 parent 14618be commit c7f29b1

File tree

1 file changed

+3
-7
lines changed

1 file changed

+3
-7
lines changed

snuba/state/rate_limit.py

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -259,8 +259,6 @@ def rate_limit_start_request(
259259
bucket = _get_bucket_key(rate_limit_prefix, rate_limit_params.bucket, shard_i)
260260
pipe.zcount(bucket, "({:f}".format(now), "+inf")
261261

262-
historical = -1
263-
concurrent = -1
264262
try:
265263
results = pipe.execute()
266264
pipe_results = iter(results)
@@ -283,18 +281,16 @@ def rate_limit_start_request(
283281
# Emit metric for timeout, but don't log since this is expected
284282
# when Redis is slow. We fail open to avoid blocking requests.
285283
metrics.increment("ratelimiter_redis_timeout", tags={"function": "start_request"})
284+
return RateLimitStats(rate=-1, concurrent=-1)
286285
except Exception as ex:
287286
# if something goes wrong, we don't want to block the request,
288287
# set the values such that they pass under any limit
289288
logger.exception(ex)
290-
finally:
291-
if historical == -1:
292-
return RateLimitStats(rate=-1, concurrent=-1)
289+
return RateLimitStats(rate=-1, concurrent=-1)
293290

294291
per_second = historical / float(state.rate_lookback_s)
295292

296-
stats = RateLimitStats(rate=per_second, concurrent=concurrent)
297-
return stats
293+
return RateLimitStats(rate=per_second, concurrent=concurrent)
298294

299295

300296
def rate_limit_finish_request(

0 commit comments

Comments
 (0)