From 5b9b8fe80f70af5a627630c1abc3b809b2e2ba26 Mon Sep 17 00:00:00 2001 From: Eugene Yurtsev Date: Wed, 9 Oct 2024 11:25:58 -0400 Subject: [PATCH] core[patch]: Ignore ASYNC110 to upgrade to newest ruff version (#27229) Ignoring ASYNC110 with explanation --- libs/core/langchain_core/rate_limiters.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/libs/core/langchain_core/rate_limiters.py b/libs/core/langchain_core/rate_limiters.py index 043e54cc38f9b..11588020f6ba7 100644 --- a/libs/core/langchain_core/rate_limiters.py +++ b/libs/core/langchain_core/rate_limiters.py @@ -249,7 +249,13 @@ async def aacquire(self, *, blocking: bool = True) -> bool: return self._consume() while not self._consume(): - await asyncio.sleep(self.check_every_n_seconds) + # This code ignores the ASYNC110 warning which is a false positive in this + # case. + # There is no external actor that can mark that the Event is done + # since the tokens are managed by the rate limiter itself. + # It needs to wake up to re-fill the tokens. + # https://docs.astral.sh/ruff/rules/async-busy-wait/ + await asyncio.sleep(self.check_every_n_seconds) # ruff: noqa: ASYNC110 return True