mirror of
https://git.datalinker.icu/comfyanonymous/ComfyUI
synced 2026-10-02 07:37:03 +08:00
use a threading.Event to make intent more explicit
This commit is contained in:
parent
b35ad9aeff
commit
b8022cf02b
@ -278,17 +278,17 @@ def cached_filename_list_(folder_name: str) -> tuple[list[str], dict[str, float]
|
|||||||
if folder_name not in filename_list_cache:
|
if folder_name not in filename_list_cache:
|
||||||
return None
|
return None
|
||||||
out = filename_list_cache[folder_name]
|
out = filename_list_cache[folder_name]
|
||||||
must_invalidate = [False]
|
must_invalidate = threading.Event()
|
||||||
folders = folder_names_and_paths[folder_name]
|
folders = folder_names_and_paths[folder_name]
|
||||||
|
|
||||||
async def check_folder_mtime(folder: str, time_modified: float):
|
async def check_folder_mtime(folder: str, time_modified: float):
|
||||||
if await AsyncFiles.getmtime(folder) != time_modified:
|
if await AsyncFiles.getmtime(folder) != time_modified:
|
||||||
must_invalidate[0] = True
|
must_invalidate.set()
|
||||||
|
|
||||||
async def check_new_dirs(x: str):
|
async def check_new_dirs(x: str):
|
||||||
if await AsyncFiles.isdir(x):
|
if await AsyncFiles.isdir(x):
|
||||||
if x not in out[1]:
|
if x not in out[1]:
|
||||||
must_invalidate[0] = True
|
must_invalidate.set()
|
||||||
|
|
||||||
def proc_thread():
|
def proc_thread():
|
||||||
asyncio.set_event_loop(asyncio.new_event_loop())
|
asyncio.set_event_loop(asyncio.new_event_loop())
|
||||||
@ -311,7 +311,7 @@ def cached_filename_list_(folder_name: str) -> tuple[list[str], dict[str, float]
|
|||||||
thread.start()
|
thread.start()
|
||||||
thread.join()
|
thread.join()
|
||||||
|
|
||||||
if must_invalidate[0]:
|
if must_invalidate.is_set():
|
||||||
return None
|
return None
|
||||||
return out
|
return out
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user