Don't open the browser while webui is still installing. wait until the webui actually starts up.

This commit is contained in:
cmdr2 2024-10-11 12:28:20 +05:30
parent 05cf4be89b
commit dfa552585e
2 changed files with 23 additions and 9 deletions

View File

@ -319,11 +319,14 @@ def getIPConfig():
def open_browser():
from easydiffusion.backend_manager import backend
config = getConfig()
ui = config.get("ui", {})
net = config.get("net", {})
port = net.get("listen_port", 9000)
if backend.is_installed():
if ui.get("open_browser_on_start", True):
import webbrowser
@ -331,9 +334,6 @@ def open_browser():
webbrowser.open(f"http://localhost:{port}")
from easydiffusion.backend_manager import backend
if backend.is_installed():
Console().print(
Panel(
"\n"

View File

@ -9,6 +9,7 @@ import shutil
from easydiffusion.app import ROOT_DIR, getConfig
from easydiffusion.model_manager import get_model_dirs
from easydiffusion.utils import log
from . import impl
from .impl import (
@ -100,6 +101,8 @@ def start_backend():
if not os.path.exists(BACKEND_DIR):
install_backend()
was_still_installing = not is_installed()
if backend_config.get("auto_update", True):
run_in_conda(["git", "add", "-A", "."], cwd=WEBUI_DIR)
run_in_conda(["git", "stash"], cwd=WEBUI_DIR)
@ -124,6 +127,17 @@ def start_backend():
while True:
try:
impl.ping(timeout=1)
if was_still_installing and not has_started: # first start
ui = config.get("ui", {})
if ui.get("open_browser_on_start", True):
import webbrowser
log.info("Opening browser..")
webbrowser.open(f"http://localhost:{port}")
has_started = True
except (TimeoutError, ConnectionError):
if has_started: # process probably died