From f691790c00021abffdf741910c9247300e5dec49 Mon Sep 17 00:00:00 2001 From: Jaikinator Date: Fri, 17 Nov 2023 15:23:11 +0100 Subject: [PATCH] aded deamon process --- test_multithreading.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/test_multithreading.py b/test_multithreading.py index 6f9834d..fb4e301 100644 --- a/test_multithreading.py +++ b/test_multithreading.py @@ -2,6 +2,8 @@ import os import time from scraibe import Scraibe + +import multiprocessing import threading import torch import gc @@ -52,7 +54,6 @@ def delete_unused_model(model_runner): global model, last_used, transcribe_active while True: - print("Checking for unused model...", transcribe_active.is_set()) _unload_porperty = (not transcribe_active.is_set() and (time.time() - last_used > 30) and model is not None) if _unload_porperty: @@ -64,7 +65,7 @@ def delete_unused_model(model_runner): model_runner.join() - print("Model deleted", threading.active_count()) + print("Model deleted") time.sleep(10) if __name__ == "__main__": @@ -72,8 +73,8 @@ if __name__ == "__main__": lock = threading.Lock() interaction = threading.Thread(target=interaction_thread) - model_runner = threading.Thread(target=model_thread) - model_deleter = threading.Thread(target=delete_unused_model, args=(model_runner,)) + model_runner = threading.Thread(target=model_thread, daemon=True) + model_deleter = threading.Thread(target=delete_unused_model, args=(model_runner,), daemon=True) model_runner.start() model_deleter.start()