Skip to content

Commit

Permalink
prebuild should have its own executor
Browse files Browse the repository at this point in the history
otherwise it can lock itself due to the very awkward hack of python threading instead of genuine async handling
  • Loading branch information
mcmonkey4eva committed Oct 3, 2024
1 parent 409f4b6 commit 6fca6e1
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions folder_paths.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
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
Expand Down Expand Up @@ -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))


Expand Down

0 comments on commit 6fca6e1

Please sign in to comment.