diff options
author | AUTOMATIC1111 <16777216c@gmail.com> | 2022-10-02 21:33:32 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-10-02 21:33:32 +0300 |
commit | ad0503c1b59de0654e3b34c72e81a3c410ba7788 (patch) | |
tree | 39c3221e99ca90b7238057bc555c5b4d63fcf960 /webui.py | |
parent | 852fd90c0dcda9cb5fbbfdf0c7308ce58034935c (diff) | |
parent | 688c4a914a6cb152b5f5e4088bace709ed3dcc35 (diff) |
Merge pull request #1454 from AUTOMATIC1111/1404-script-reload-without-restart
Gradio+custom script+js+css reload without model reloading
Diffstat (limited to 'webui.py')
-rw-r--r-- | webui.py | 41 |
1 files changed, 32 insertions, 9 deletions
@@ -1,4 +1,9 @@ import os
+import threading
+import time
+import importlib
+from modules import devices
+from modules.paths import script_path
import signal
import threading
@@ -82,16 +87,34 @@ def webui(): signal.signal(signal.SIGINT, sigint_handler)
- demo = modules.ui.create_ui(wrap_gradio_gpu_call=wrap_gradio_gpu_call)
+ while 1:
+
+ demo = modules.ui.create_ui(wrap_gradio_gpu_call=wrap_gradio_gpu_call)
+
+ demo.launch(
+ share=cmd_opts.share,
+ server_name="0.0.0.0" if cmd_opts.listen else None,
+ server_port=cmd_opts.port,
+ debug=cmd_opts.gradio_debug,
+ auth=[tuple(cred.split(':')) for cred in cmd_opts.gradio_auth.strip('"').split(',')] if cmd_opts.gradio_auth else None,
+ inbrowser=cmd_opts.autolaunch,
+ prevent_thread_lock=True
+ )
+
+ while 1:
+ time.sleep(0.5)
+ if getattr(demo,'do_restart',False):
+ time.sleep(0.5)
+ demo.close()
+ time.sleep(0.5)
+ break
+
+ print('Reloading Custom Scripts')
+ modules.scripts.reload_scripts(os.path.join(script_path, "scripts"))
+ print('Reloading modules: modules.ui')
+ importlib.reload(modules.ui)
+ print('Restarting Gradio')
- demo.launch(
- share=cmd_opts.share,
- server_name="0.0.0.0" if cmd_opts.listen else None,
- server_port=cmd_opts.port,
- debug=cmd_opts.gradio_debug,
- auth=[tuple(cred.split(':')) for cred in cmd_opts.gradio_auth.strip('"').split(',')] if cmd_opts.gradio_auth else None,
- inbrowser=cmd_opts.autolaunch,
- )
if __name__ == "__main__":
|