Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Overbill1683
Stable Diffusion Webui
提交
85b4f899
S
Stable Diffusion Webui
项目概览
Overbill1683
/
Stable Diffusion Webui
10 个月 前同步成功
通知
1748
Star
81
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
分析
仓库
DevOps
项目成员
Pages
S
Stable Diffusion Webui
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Pages
分析
分析
仓库分析
DevOps
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
提交
体验新版 GitCode,发现更多精彩内容 >>
提交
85b4f899
编写于
5月 11, 2023
作者:
A
Aarni Koskela
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Replace state.need_restart with state.server_command + replace poll loop with signal
上级
4b07f2f5
变更
4
显示空白变更内容
内联
并排
Showing
4 changed file
with
68 addition
and
26 deletion
+68
-26
modules/shared.py
modules/shared.py
+41
-1
modules/ui.py
modules/ui.py
+1
-5
modules/ui_extensions.py
modules/ui_extensions.py
+2
-5
webui.py
webui.py
+24
-15
未找到文件。
modules/shared.py
浏览文件 @
85b4f899
...
...
@@ -2,6 +2,7 @@ import datetime
import
json
import
os
import
sys
import
threading
import
time
import
gradio
as
gr
...
...
@@ -110,8 +111,47 @@ class State:
id_live_preview
=
0
textinfo
=
None
time_start
=
None
need_restart
=
False
server_start
=
None
_server_command_signal
=
threading
.
Event
()
_server_command
:
str
|
None
=
None
@
property
def
need_restart
(
self
)
->
bool
:
# Compatibility getter for need_restart.
return
self
.
server_command
==
"restart"
@
need_restart
.
setter
def
need_restart
(
self
,
value
:
bool
)
->
None
:
# Compatibility setter for need_restart.
if
value
:
self
.
server_command
=
"restart"
@
property
def
server_command
(
self
):
return
self
.
_server_command
@
server_command
.
setter
def
server_command
(
self
,
value
:
str
|
None
)
->
None
:
"""
Set the server command to `value` and signal that it's been set.
"""
self
.
_server_command
=
value
self
.
_server_command_signal
.
set
()
def
wait_for_server_command
(
self
,
timeout
:
float
|
None
=
None
)
->
str
|
None
:
"""
Wait for server command to get set; return and clear the value and signal.
"""
if
self
.
_server_command_signal
.
wait
(
timeout
):
self
.
_server_command_signal
.
clear
()
req
=
self
.
_server_command
self
.
_server_command
=
None
return
req
return
None
def
request_restart
(
self
)
->
None
:
self
.
interrupt
()
self
.
server_command
=
True
def
skip
(
self
):
self
.
skipped
=
True
...
...
modules/ui.py
浏览文件 @
85b4f899
...
...
@@ -1609,12 +1609,8 @@ def create_ui():
outputs
=
[]
)
def
request_restart
():
shared
.
state
.
interrupt
()
shared
.
state
.
need_restart
=
True
restart_gradio
.
click
(
fn
=
request_restart
,
fn
=
shared
.
state
.
request_restart
,
_js
=
'restart_reload'
,
inputs
=
[],
outputs
=
[],
...
...
modules/ui_extensions.py
浏览文件 @
85b4f899
...
...
@@ -52,9 +52,7 @@ def apply_and_restart(disable_list, update_list, disable_all):
shared
.
opts
.
disabled_extensions
=
disabled
shared
.
opts
.
disable_all_extensions
=
disable_all
shared
.
opts
.
save
(
shared
.
config_filename
)
shared
.
state
.
interrupt
()
shared
.
state
.
need_restart
=
True
shared
.
state
.
request_restart
()
def
save_config_state
(
name
):
...
...
@@ -92,8 +90,7 @@ def restore_config_state(confirmed, config_state_name, restore_type):
if
restore_type
==
"webui"
or
restore_type
==
"both"
:
config_states
.
restore_webui_config
(
config_state
)
shared
.
state
.
interrupt
()
shared
.
state
.
need_restart
=
True
shared
.
state
.
request_restart
()
return
""
...
...
webui.py
浏览文件 @
85b4f899
...
...
@@ -234,6 +234,9 @@ def initialize():
print
(
f
'Interrupted with signal
{
sig
}
in
{
frame
}
'
)
os
.
_exit
(
0
)
if
not
os
.
environ
.
get
(
"COVERAGE_RUN"
):
# Don't install the immediate-quit handler when running under coverage,
# as then the coverage report won't be generated.
signal
.
signal
(
signal
.
SIGINT
,
sigint_handler
)
...
...
@@ -255,19 +258,6 @@ def create_api(app):
return
api
def
wait_on_server
(
demo
=
None
):
while
1
:
time
.
sleep
(
0.5
)
if
shared
.
state
.
need_restart
:
shared
.
state
.
need_restart
=
False
time
.
sleep
(
0.5
)
demo
.
close
()
time
.
sleep
(
0.5
)
modules
.
script_callbacks
.
app_reload_callback
()
break
def
api_only
():
initialize
()
...
...
@@ -328,6 +318,7 @@ def webui():
inbrowser
=
cmd_opts
.
autolaunch
,
prevent_thread_lock
=
True
)
# after initial launch, disable --autolaunch for subsequent restarts
cmd_opts
.
autolaunch
=
False
...
...
@@ -359,8 +350,26 @@ def webui():
redirector
.
get
(
"/"
)
gradio
.
mount_gradio_app
(
redirector
,
shared
.
demo
,
path
=
f
"/
{
cmd_opts
.
subpath
}
"
)
wait_on_server
(
shared
.
demo
)
try
:
while
True
:
server_command
=
shared
.
state
.
wait_for_server_command
(
timeout
=
5
)
if
server_command
:
if
server_command
in
(
"stop"
,
"restart"
):
break
else
:
print
(
f
"Unknown server command:
{
server_command
}
"
)
except
KeyboardInterrupt
:
server_command
=
"stop"
if
server_command
==
"stop"
:
# If we catch a keyboard interrupt, we want to stop the server and exit.
print
(
'Caught KeyboardInterrupt, stopping...'
)
shared
.
demo
.
close
()
break
print
(
'Restarting UI...'
)
shared
.
demo
.
close
()
time
.
sleep
(
0.5
)
modules
.
script_callbacks
.
app_reload_callback
()
startup_timer
.
reset
()
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录