Merge branch 'main' into ts-pack

This commit is contained in:
Paul Gauthier 2025-02-07 18:10:37 -08:00
commit 927b5bc8cc
2 changed files with 13 additions and 1 deletions

View file

@ -168,6 +168,7 @@ class Coder:
use_kwargs.update(kwargs) # override passed kwargs use_kwargs.update(kwargs) # override passed kwargs
kwargs = use_kwargs kwargs = use_kwargs
from_coder.ok_to_warm_cache = False
for coder in coders.__all__: for coder in coders.__all__:
if hasattr(coder, "edit_format") and coder.edit_format == edit_format: if hasattr(coder, "edit_format") and coder.edit_format == edit_format:
@ -264,6 +265,8 @@ class Coder:
return lines return lines
ok_to_warm_cache = False
def __init__( def __init__(
self, self,
main_model, main_model,
@ -1200,6 +1203,8 @@ class Coder:
return return
if not self.num_cache_warming_pings: if not self.num_cache_warming_pings:
return return
if not self.ok_to_warm_cache:
return
delay = 5 * 60 - 5 delay = 5 * 60 - 5
self.next_cache_warm = time.time() + delay self.next_cache_warm = time.time() + delay
@ -1210,7 +1215,7 @@ class Coder:
return return
def warm_cache_worker(): def warm_cache_worker():
while True: while self.ok_to_warm_cache:
time.sleep(1) time.sleep(1)
if self.warming_pings_left <= 0: if self.warming_pings_left <= 0:
continue continue
@ -1535,6 +1540,10 @@ class Coder:
return res 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): def add_assistant_reply_to_cur_messages(self):
if self.partial_response_content: if self.partial_response_content:
self.cur_messages += [dict(role="assistant", content=self.partial_response_content)] self.cur_messages += [dict(role="assistant", content=self.partial_response_content)]

View file

@ -1060,10 +1060,13 @@ def main(argv=None, input=None, output=None, force_git_root=None, return_coder=F
while True: while True:
try: try:
coder.ok_to_warm_cache = True
coder.run() coder.run()
analytics.event("exit", reason="Completed main CLI coder.run") analytics.event("exit", reason="Completed main CLI coder.run")
return return
except SwitchCoder as switch: except SwitchCoder as switch:
coder.ok_to_warm_cache = False
kwargs = dict(io=io, from_coder=coder) kwargs = dict(io=io, from_coder=coder)
kwargs.update(switch.kwargs) kwargs.update(switch.kwargs)
if "show_announcements" in kwargs: if "show_announcements" in kwargs: