Let ThreadPool exit gracefully. (#3653)

### What problem does this PR solve?

#3646

### Type of change

- [x] Bug Fix (non-breaking change which fixes an issue)
This commit is contained in:
Kevin Hu
2024-11-26 16:31:07 +08:00
committed by GitHub
parent 5c59651bda
commit 0891a393d7
5 changed files with 37 additions and 39 deletions

View File

@ -366,7 +366,7 @@ class OllamaChat(Base):
keep_alive=-1
)
ans = response["message"]["content"].strip()
return ans, response["eval_count"] + response.get("prompt_eval_count", 0)
return ans, response.get("eval_count", 0) + response.get("prompt_eval_count", 0)
except Exception as e:
return "**ERROR**: " + str(e), 0

View File

@ -492,6 +492,7 @@ def report_status():
logging.exception("report_status got exception")
time.sleep(30)
def analyze_heap(snapshot1: tracemalloc.Snapshot, snapshot2: tracemalloc.Snapshot, snapshot_id: int, dump_full: bool):
msg = ""
if dump_full:
@ -508,6 +509,7 @@ def analyze_heap(snapshot1: tracemalloc.Snapshot, snapshot2: tracemalloc.Snapsho
msg += '\n'.join(stat.traceback.format())
logging.info(msg)
def main():
settings.init_settings()
background_thread = threading.Thread(target=report_status)