Skip to content

Commit a94370d

Browse files
committed
Fix incorrect time when checking concurrency
1 parent 989f27a commit a94370d

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

posthog/clickhouse/client/limit.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,6 @@ def use(self, *args, **kwargs):
9595
running_tasks_key = self.get_task_key(*args, **kwargs) if self.get_task_key else task_name
9696
task_id = self.get_task_id(*args, **kwargs)
9797
team_id: Optional[int] = kwargs.get("team_id", None)
98-
current_time = self.get_time()
9998

10099
max_concurrency = self.max_concurrency
101100
in_beta = kwargs.get("is_api") and (team_id in settings.API_QUERIES_PER_TEAM)
@@ -109,7 +108,9 @@ def use(self, *args, **kwargs):
109108
count = 1
110109
# Atomically check, remove expired if limit hit, and add the new task
111110
while (
112-
self.redis_client.eval(lua_script, 1, running_tasks_key, current_time, task_id, max_concurrency, self.ttl)
111+
self.redis_client.eval(
112+
lua_script, 1, running_tasks_key, self.get_time(), task_id, max_concurrency, self.ttl
113+
)
113114
== 0
114115
):
115116
from posthog.rate_limit import team_is_allowed_to_bypass_throttle

0 commit comments

Comments
 (0)