diff --git a/aider/coders/base_coder.py b/aider/coders/base_coder.py index 85228df2b..7e228dd5f 100755 --- a/aider/coders/base_coder.py +++ b/aider/coders/base_coder.py @@ -168,6 +168,7 @@ class Coder: use_kwargs.update(kwargs) # override passed kwargs kwargs = use_kwargs + from_coder.ok_to_warm_cache = False for coder in coders.__all__: if hasattr(coder, "edit_format") and coder.edit_format == edit_format: @@ -264,6 +265,8 @@ class Coder: return lines + ok_to_warm_cache = False + def __init__( self, main_model, @@ -1200,6 +1203,8 @@ class Coder: return if not self.num_cache_warming_pings: return + if not self.ok_to_warm_cache: + return delay = 5 * 60 - 5 self.next_cache_warm = time.time() + delay @@ -1210,7 +1215,7 @@ class Coder: return def warm_cache_worker(): - while True: + while self.ok_to_warm_cache: time.sleep(1) if self.warming_pings_left <= 0: continue @@ -1535,6 +1540,10 @@ class Coder: return res + def __del__(self): + """Cleanup when the Coder object is destroyed.""" + self.ok_to_warm_cache = False + def add_assistant_reply_to_cur_messages(self): if self.partial_response_content: self.cur_messages += [dict(role="assistant", content=self.partial_response_content)] diff --git a/aider/main.py b/aider/main.py index f88b8268b..398737079 100644 --- a/aider/main.py +++ b/aider/main.py @@ -1060,10 +1060,13 @@ def main(argv=None, input=None, output=None, force_git_root=None, return_coder=F while True: try: + coder.ok_to_warm_cache = True coder.run() analytics.event("exit", reason="Completed main CLI coder.run") return except SwitchCoder as switch: + coder.ok_to_warm_cache = False + kwargs = dict(io=io, from_coder=coder) kwargs.update(switch.kwargs) if "show_announcements" in kwargs: