prebuild should have its own executor

otherwise it can lock itself due to the very awkward hack of python threading instead of genuine async handling
This commit is contained in:
Alex "mcmonkey" Goodwin 2024-10-03 13:27:04 -07:00
parent 409f4b6583
commit 6fca6e1746

View File

@ -5,7 +5,6 @@ import os
import time
import mimetypes
import logging
import time
from typing import Set, List, Dict, Tuple, Literal
from collections.abc import Collection
from concurrent.futures import ThreadPoolExecutor
@ -217,13 +216,14 @@ def get_folder_paths(folder_name: str) -> list[str]:
def prebuild_lists():
start_time = time.time()
calls = []
for folder_name in folder_names_and_paths:
calls.append(async_executor.submit(lambda: get_filename_list(folder_name)))
for call in calls:
call.result()
end_time = time.time()
start_time = time.perf_counter()
with ThreadPoolExecutor(32) as executor:
calls = []
for folder_name in folder_names_and_paths:
calls.append(executor.submit(lambda: get_filename_list(folder_name)))
for call in calls:
call.result()
end_time = time.perf_counter()
logging.info("Scanned model lists in {:.2f} seconds".format(end_time - start_time))