Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
S
Stable Diffusion Webui
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Locked Files
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Security & Compliance
Security & Compliance
Dependency List
License Compliance
Packages
Packages
List
Container Registry
Analytics
Analytics
CI / CD
Code Review
Insights
Issues
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
novelai-storage
Stable Diffusion Webui
Commits
a3fdef4e
Commit
a3fdef4e
authored
Aug 21, 2023
by
AUTOMATIC1111
Committed by
GitHub
Aug 21, 2023
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #12707 from AnyISalIn/dev
feat: replace threading.Lock() to FIFOLock
parents
dfd6ea3f
71a0f6ef
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
45 additions
and
4 deletions
+45
-4
modules/call_queue.py
modules/call_queue.py
+2
-3
modules/fifo_lock.py
modules/fifo_lock.py
+37
-0
modules/progress.py
modules/progress.py
+6
-1
No files found.
modules/call_queue.py
View file @
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
View file @
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
View file @
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
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment