Skip to content
GitLab
菜单
为什么选择 GitLab
定价
联系销售
探索
为什么选择 GitLab
定价
联系销售
探索
登录
获取免费试用
主导航
搜索或转到…
项目
S
Stable Diffusion Webui
管理
动态
成员
代码
仓库
分支
提交
标签
仓库图
比较修订版本
部署
模型注册表
分析
模型实验
帮助
帮助
支持
GitLab 文档
比较 GitLab 各版本
社区论坛
为极狐GitLab 提交贡献
提交反馈
隐私声明
快捷键
?
新增功能
4
代码片段
群组
项目
显示更多面包屑
Hunter0726
Stable Diffusion Webui
提交
a3fdef4e
未验证
提交
a3fdef4e
编辑于
1 year ago
作者:
AUTOMATIC1111
提交者:
GitHub
1 year ago
浏览文件
操作
下载
差异文件
Merge pull request #12707 from AnyISalIn/dev
feat: replace threading.Lock() to FIFOLock
上级
dfd6ea3f
71a0f6ef
No related branches found
No related tags found
无相关合并请求
变更
3
隐藏空白变更内容
行内
左右并排
显示
3 个更改的文件
modules/call_queue.py
+2
-3
2 个添加, 3 个删除
modules/call_queue.py
modules/fifo_lock.py
+37
-0
37 个添加, 0 个删除
modules/fifo_lock.py
modules/progress.py
+6
-1
6 个添加, 1 个删除
modules/progress.py
有
45 个添加
和
4 个删除
modules/call_queue.py
+
2
−
3
浏览文件 @
a3fdef4e
from
functools
import
wraps
import
html
import
threading
import
time
from
modules
import
shared
,
progress
,
errors
,
devices
from
modules
import
shared
,
progress
,
errors
,
devices
,
fifo_lock
queue_lock
=
threading
.
Lock
()
queue_lock
=
fifo_lock
.
FIFO
Lock
()
def
wrap_queued_call
(
func
):
...
...
此差异已折叠。
点击以展开。
modules/fifo_lock.py
0 → 100644
+
37
−
0
浏览文件 @
a3fdef4e
import
threading
import
collections
# reference: https://gist.github.com/vitaliyp/6d54dd76ca2c3cdfc1149d33007dc34a
class
FIFOLock
(
object
):
def
__init__
(
self
):
self
.
_lock
=
threading
.
Lock
()
self
.
_inner_lock
=
threading
.
Lock
()
self
.
_pending_threads
=
collections
.
deque
()
def
acquire
(
self
,
blocking
=
True
):
with
self
.
_inner_lock
:
lock_acquired
=
self
.
_lock
.
acquire
(
False
)
if
lock_acquired
:
return
True
elif
not
blocking
:
return
False
release_event
=
threading
.
Event
()
self
.
_pending_threads
.
append
(
release_event
)
release_event
.
wait
()
return
self
.
_lock
.
acquire
()
def
release
(
self
):
with
self
.
_inner_lock
:
if
self
.
_pending_threads
:
release_event
=
self
.
_pending_threads
.
popleft
()
release_event
.
set
()
self
.
_lock
.
release
()
__enter__
=
acquire
def
__exit__
(
self
,
t
,
v
,
tb
):
self
.
release
()
此差异已折叠。
点击以展开。
modules/progress.py
+
6
−
1
浏览文件 @
a3fdef4e
...
...
@@ -72,7 +72,12 @@ def progressapi(req: ProgressRequest):
completed
=
req
.
id_task
in
finished_tasks
if
not
active
:
return
ProgressResponse
(
active
=
active
,
queued
=
queued
,
completed
=
completed
,
id_live_preview
=-
1
,
textinfo
=
"
In queue...
"
if
queued
else
"
Waiting...
"
)
textinfo
=
"
Waiting...
"
if
queued
:
sorted_queued
=
sorted
(
pending_tasks
.
keys
(),
key
=
lambda
x
:
pending_tasks
[
x
])
queue_index
=
sorted_queued
.
index
(
req
.
id_task
)
textinfo
=
"
In queue: {}/{}
"
.
format
(
queue_index
+
1
,
len
(
sorted_queued
))
return
ProgressResponse
(
active
=
active
,
queued
=
queued
,
completed
=
completed
,
id_live_preview
=-
1
,
textinfo
=
textinfo
)
progress
=
0
...
...
此差异已折叠。
点击以展开。
预览
0%
加载中
请重试
或
添加新附件
.
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
保存评论
取消
想要评论请
注册
或
登录