mirror of
https://github.com/Aider-AI/aider.git
synced 2025-06-01 02:05: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
|
||||
|
||||
_cache_warming_stop = False
|
||||
|
||||
def __init__(
|
||||
self,
|
||||
main_model,
|
||||
|
@ -1207,12 +1209,13 @@ class Coder:
|
|||
self.next_cache_warm = time.time() + delay
|
||||
self.warming_pings_left = self.num_cache_warming_pings
|
||||
self.cache_warming_chunks = chunks
|
||||
self._cache_warming_stop = False
|
||||
|
||||
if self.cache_warming_thread:
|
||||
return
|
||||
|
||||
def warm_cache_worker():
|
||||
while True:
|
||||
while not self._cache_warming_stop:
|
||||
dump(self.warming_pings_left)
|
||||
time.sleep(1)
|
||||
if self.warming_pings_left <= 0:
|
||||
|
@ -1538,6 +1541,10 @@ class Coder:
|
|||
|
||||
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):
|
||||
if 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