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
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)]

View file

@ -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: