mirror of
https://github.com/Aider-AI/aider.git
synced 2025-06-02 10:45:00 +00:00
refactor: Improve cache warming thread cleanup in Coder class
This commit is contained in:
parent
3b5024749f
commit
a682b50fd4
1 changed files with 8 additions and 1 deletions
|
@ -264,6 +264,8 @@ class Coder:
|
||||||
|
|
||||||
return lines
|
return lines
|
||||||
|
|
||||||
|
_cache_warming_stop = False
|
||||||
|
|
||||||
def __init__(
|
def __init__(
|
||||||
self,
|
self,
|
||||||
main_model,
|
main_model,
|
||||||
|
@ -1207,12 +1209,13 @@ class Coder:
|
||||||
self.next_cache_warm = time.time() + delay
|
self.next_cache_warm = time.time() + delay
|
||||||
self.warming_pings_left = self.num_cache_warming_pings
|
self.warming_pings_left = self.num_cache_warming_pings
|
||||||
self.cache_warming_chunks = chunks
|
self.cache_warming_chunks = chunks
|
||||||
|
self._cache_warming_stop = False
|
||||||
|
|
||||||
if self.cache_warming_thread:
|
if self.cache_warming_thread:
|
||||||
return
|
return
|
||||||
|
|
||||||
def warm_cache_worker():
|
def warm_cache_worker():
|
||||||
while True:
|
while not self._cache_warming_stop:
|
||||||
dump(self.warming_pings_left)
|
dump(self.warming_pings_left)
|
||||||
time.sleep(1)
|
time.sleep(1)
|
||||||
if self.warming_pings_left <= 0:
|
if self.warming_pings_left <= 0:
|
||||||
|
@ -1538,6 +1541,10 @@ class Coder:
|
||||||
|
|
||||||
return res
|
return res
|
||||||
|
|
||||||
|
def __del__(self):
|
||||||
|
"""Cleanup when the Coder object is destroyed."""
|
||||||
|
self._cache_warming_stop = True
|
||||||
|
|
||||||
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)]
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue