mirror of
https://git.datalinker.icu/comfyanonymous/ComfyUI
synced 2026-09-13 17:47:11 +08:00
.shutdown isn't so friendly :(
This commit is contained in:
parent
5d8a0b7afd
commit
163bfff829
@ -1,7 +1,6 @@
|
||||
from __future__ import annotations
|
||||
|
||||
import asyncio, threading
|
||||
from functools import partial, wraps
|
||||
import threading
|
||||
import os
|
||||
import time
|
||||
import mimetypes
|
||||
@ -199,23 +198,31 @@ def recursive_search(directory: str, excluded_dir_names: list[str] | None=None)
|
||||
logging.debug("recursive file list on directory {}".format(directory))
|
||||
|
||||
with ThreadPoolExecutor() as executor:
|
||||
calls = []
|
||||
|
||||
def proc_subdir(path: str):
|
||||
dirs[path] = os.path.getmtime(path)
|
||||
|
||||
def handle(file):
|
||||
if not os.path.isdir(file):
|
||||
relative_path = os.path.relpath(file, directory)
|
||||
result.append(relative_path)
|
||||
return
|
||||
executor.submit(lambda: proc_subdir(file))
|
||||
for subdir in os.listdir(file):
|
||||
path = os.path.join(file, subdir)
|
||||
if subdir not in excluded_dir_names:
|
||||
executor.submit(lambda: handle(path))
|
||||
try:
|
||||
if not os.path.isdir(file):
|
||||
relative_path = os.path.relpath(file, directory)
|
||||
result.append(relative_path)
|
||||
return
|
||||
|
||||
calls.append(executor.submit(lambda: proc_subdir(file)))
|
||||
|
||||
for subdir in os.listdir(file):
|
||||
path = os.path.join(file, subdir)
|
||||
if subdir not in excluded_dir_names:
|
||||
calls.append(executor.submit(lambda: handle(path)))
|
||||
except Exception as e:
|
||||
logging.error(f"Error while handling {file}: {e}")
|
||||
|
||||
calls.append(executor.submit(lambda: handle(directory)))
|
||||
while len(calls) > 0:
|
||||
calls.pop().result()
|
||||
|
||||
executor.submit(lambda: handle(directory))
|
||||
executor.shutdown(wait=True)
|
||||
|
||||
logging.debug("found {} files".format(len(result)))
|
||||
return result, dirs
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user