fix: known issue

This commit is contained in:
DDSRem
2025-11-19 19:46:46 +08:00
parent f589fcc2d0
commit 0dc0d66549
2 changed files with 6 additions and 5 deletions

View File

@@ -400,9 +400,10 @@ class QpsRateLimiter:
"""
获取调用许可,阻塞直到满足速率限制
"""
sleep_duration = 0
with self.lock:
now = time.monotonic()
wait_time = self.next_call_time - now
if wait_time > 0:
time.sleep(wait_time)
sleep_duration = self.next_call_time - now
self.next_call_time = max(now, self.next_call_time) + self.interval
if sleep_duration > 0:
time.sleep(sleep_duration)