mirror of
https://github.com/AUTOMATIC1111/stable-diffusion-webui.git
synced 2025-01-17 11:50:18 +08:00
call run_extensions_installer() using executor
This commit is contained in:
parent
5865da28d1
commit
5571616aa6
@ -12,6 +12,7 @@ import json
|
|||||||
import shlex
|
import shlex
|
||||||
from functools import lru_cache
|
from functools import lru_cache
|
||||||
|
|
||||||
|
from concurrent.futures import ThreadPoolExecutor, as_completed
|
||||||
from modules import cmd_args, errors
|
from modules import cmd_args, errors
|
||||||
from modules.paths_internal import script_path, extensions_dir
|
from modules.paths_internal import script_path, extensions_dir
|
||||||
from modules.timer import startup_timer
|
from modules.timer import startup_timer
|
||||||
@ -228,7 +229,10 @@ def version_check(commit):
|
|||||||
def run_extension_installer(extension_dir):
|
def run_extension_installer(extension_dir):
|
||||||
path_installer = os.path.join(extension_dir, "install.py")
|
path_installer = os.path.join(extension_dir, "install.py")
|
||||||
if not os.path.isfile(path_installer):
|
if not os.path.isfile(path_installer):
|
||||||
return
|
return False
|
||||||
|
|
||||||
|
dirname = os.path.basename(extension_dir)
|
||||||
|
logging.debug(f"Installing {dirname}")
|
||||||
|
|
||||||
try:
|
try:
|
||||||
env = os.environ.copy()
|
env = os.environ.copy()
|
||||||
@ -240,6 +244,8 @@ def run_extension_installer(extension_dir):
|
|||||||
except Exception as e:
|
except Exception as e:
|
||||||
errors.report(str(e))
|
errors.report(str(e))
|
||||||
|
|
||||||
|
return True
|
||||||
|
|
||||||
|
|
||||||
def list_extensions(settings_file):
|
def list_extensions(settings_file):
|
||||||
settings = {}
|
settings = {}
|
||||||
@ -267,14 +273,19 @@ def run_extensions_installers(settings_file):
|
|||||||
return
|
return
|
||||||
|
|
||||||
with startup_timer.subcategory("run extensions installers"):
|
with startup_timer.subcategory("run extensions installers"):
|
||||||
|
paths = {}
|
||||||
for dirname_extension in list_extensions(settings_file):
|
for dirname_extension in list_extensions(settings_file):
|
||||||
logging.debug(f"Installing {dirname_extension}")
|
|
||||||
|
|
||||||
path = os.path.join(extensions_dir, dirname_extension)
|
path = os.path.join(extensions_dir, dirname_extension)
|
||||||
|
|
||||||
if os.path.isdir(path):
|
if os.path.isdir(path):
|
||||||
run_extension_installer(path)
|
paths[dirname_extension] = path
|
||||||
startup_timer.record(dirname_extension)
|
|
||||||
|
with ThreadPoolExecutor(max_workers=2) as executor:
|
||||||
|
futures = {executor.submit(run_extension_installer, path): dirname_extension for dirname_extension, path in paths.items()}
|
||||||
|
for future in as_completed(futures):
|
||||||
|
dirname_extension = futures[future]
|
||||||
|
if future.result():
|
||||||
|
startup_timer.record(dirname_extension)
|
||||||
|
|
||||||
|
|
||||||
re_requirement = re.compile(r"\s*([-_a-zA-Z0-9]+)\s*(?:==\s*([-+_.a-zA-Z0-9]+))?\s*")
|
re_requirement = re.compile(r"\s*([-_a-zA-Z0-9]+)\s*(?:==\s*([-+_.a-zA-Z0-9]+))?\s*")
|
||||||
|
Loading…
Reference in New Issue
Block a user