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
3662a274
Commit
3662a274
authored
Dec 16, 2022
by
rucadi
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add polling callback
parent
226d840e
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
13 additions
and
0 deletions
+13
-0
modules/script_callbacks.py
modules/script_callbacks.py
+12
-0
webui.py
webui.py
+1
-0
No files found.
modules/script_callbacks.py
View file @
3662a274
...
@@ -74,6 +74,7 @@ callback_map = dict(
...
@@ -74,6 +74,7 @@ callback_map = dict(
callbacks_infotext_pasted
=
[],
callbacks_infotext_pasted
=
[],
callbacks_script_unloaded
=
[],
callbacks_script_unloaded
=
[],
callbacks_before_ui
=
[],
callbacks_before_ui
=
[],
callbacks_on_polling
=
[],
)
)
...
@@ -89,6 +90,12 @@ def app_started_callback(demo: Optional[Blocks], app: FastAPI):
...
@@ -89,6 +90,12 @@ def app_started_callback(demo: Optional[Blocks], app: FastAPI):
except
Exception
:
except
Exception
:
report_exception
(
c
,
'app_started_callback'
)
report_exception
(
c
,
'app_started_callback'
)
def
app_polling_callback
(
demo
:
Optional
[
Blocks
],
app
:
FastAPI
):
for
c
in
callback_map
[
'callbacks_on_polling'
]:
try
:
c
.
callback
()
except
Exception
:
report_exception
(
c
,
'callbacks_on_polling'
)
def
model_loaded_callback
(
sd_model
):
def
model_loaded_callback
(
sd_model
):
for
c
in
callback_map
[
'callbacks_model_loaded'
]:
for
c
in
callback_map
[
'callbacks_model_loaded'
]:
...
@@ -227,6 +234,11 @@ def on_app_started(callback):
...
@@ -227,6 +234,11 @@ def on_app_started(callback):
add_callback
(
callback_map
[
'callbacks_app_started'
],
callback
)
add_callback
(
callback_map
[
'callbacks_app_started'
],
callback
)
def
on_polling
(
callback
):
"""register a function to be called on each polling of the server."""
add_callback
(
callback_map
[
'callbacks_on_polling'
],
callback
)
def
on_model_loaded
(
callback
):
def
on_model_loaded
(
callback
):
"""register a function to be called when the stable diffusion model is created; the model is
"""register a function to be called when the stable diffusion model is created; the model is
passed as an argument; this function is also called when the script is reloaded. """
passed as an argument; this function is also called when the script is reloaded. """
...
...
webui.py
View file @
3662a274
...
@@ -171,6 +171,7 @@ def create_api(app):
...
@@ -171,6 +171,7 @@ def create_api(app):
def
wait_on_server
(
demo
=
None
):
def
wait_on_server
(
demo
=
None
):
while
1
:
while
1
:
time
.
sleep
(
0.5
)
time
.
sleep
(
0.5
)
modules
.
script_callbacks
.
app_polling_callback
(
None
,
demo
)
if
shared
.
state
.
need_restart
:
if
shared
.
state
.
need_restart
:
shared
.
state
.
need_restart
=
False
shared
.
state
.
need_restart
=
False
time
.
sleep
(
0.5
)
time
.
sleep
(
0.5
)
...
...
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