mirror of
https://github.com/Aider-AI/aider.git
synced 2025-05-30 09:14:59 +00:00
refactor: Centralize retry timeout and use consistent value
This commit is contained in:
parent
26058c89fe
commit
6bb9b2567f
2 changed files with 5 additions and 3 deletions
|
@ -27,7 +27,7 @@ from aider.llm import litellm
|
||||||
from aider.repo import ANY_GIT_ERROR, GitRepo
|
from aider.repo import ANY_GIT_ERROR, GitRepo
|
||||||
from aider.repomap import RepoMap
|
from aider.repomap import RepoMap
|
||||||
from aider.run_cmd import run_cmd
|
from aider.run_cmd import run_cmd
|
||||||
from aider.sendchat import retry_exceptions, send_completion
|
from aider.sendchat import RETRY_TIMEOUT, retry_exceptions, send_completion
|
||||||
from aider.utils import format_content, format_messages, format_tokens, is_image_file
|
from aider.utils import format_content, format_messages, format_tokens, is_image_file
|
||||||
|
|
||||||
from ..dump import dump # noqa: F401
|
from ..dump import dump # noqa: F401
|
||||||
|
@ -1131,7 +1131,7 @@ class Coder:
|
||||||
except retry_exceptions() as err:
|
except retry_exceptions() as err:
|
||||||
self.io.tool_warning(str(err))
|
self.io.tool_warning(str(err))
|
||||||
retry_delay *= 2
|
retry_delay *= 2
|
||||||
if retry_delay > 60:
|
if retry_delay > RETRY_TIMEOUT:
|
||||||
break
|
break
|
||||||
self.io.tool_output(f"Retrying in {retry_delay:.1f} seconds...")
|
self.io.tool_output(f"Retrying in {retry_delay:.1f} seconds...")
|
||||||
time.sleep(retry_delay)
|
time.sleep(retry_delay)
|
||||||
|
|
|
@ -13,6 +13,8 @@ CACHE_PATH = "~/.aider.send.cache.v1"
|
||||||
CACHE = None
|
CACHE = None
|
||||||
# CACHE = Cache(CACHE_PATH)
|
# CACHE = Cache(CACHE_PATH)
|
||||||
|
|
||||||
|
RETRY_TIMEOUT = 60
|
||||||
|
|
||||||
|
|
||||||
def retry_exceptions():
|
def retry_exceptions():
|
||||||
import httpx
|
import httpx
|
||||||
|
@ -36,7 +38,7 @@ def lazy_litellm_retry_decorator(func):
|
||||||
decorated_func = backoff.on_exception(
|
decorated_func = backoff.on_exception(
|
||||||
backoff.expo,
|
backoff.expo,
|
||||||
retry_exceptions(),
|
retry_exceptions(),
|
||||||
max_time=60,
|
max_time=RETRY_TIMEOUT,
|
||||||
on_backoff=lambda details: print(
|
on_backoff=lambda details: print(
|
||||||
f"{details.get('exception', 'Exception')}\nRetry in {details['wait']:.1f} seconds."
|
f"{details.get('exception', 'Exception')}\nRetry in {details['wait']:.1f} seconds."
|
||||||
),
|
),
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue