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
0c8825b2
Commit
0c8825b2
authored
Dec 16, 2022
by
rucadi
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add a callback called before reloading the server
parent
1742c04b
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
13 additions
and
1 deletion
+13
-1
modules/script_callbacks.py
modules/script_callbacks.py
+12
-1
webui.py
webui.py
+1
-0
No files found.
modules/script_callbacks.py
View file @
0c8825b2
...
...
@@ -64,6 +64,7 @@ callback_map = dict(
callbacks_before_component
=
[],
callbacks_after_component
=
[],
callbacks_on_polling
=
[],
callbacks_on_reload
=
[],
)
...
...
@@ -71,7 +72,6 @@ def clear_callbacks():
for
callback_list
in
callback_map
.
values
():
callback_list
.
clear
()
def
app_started_callback
(
demo
:
Optional
[
Blocks
],
app
:
FastAPI
):
for
c
in
callback_map
[
'callbacks_app_started'
]:
try
:
...
...
@@ -86,6 +86,14 @@ def app_polling_callback(demo: Optional[Blocks], app: FastAPI):
except
Exception
:
report_exception
(
c
,
'callbacks_on_polling'
)
def
app_reload_callback
(
demo
:
Optional
[
Blocks
],
app
:
FastAPI
):
for
c
in
callback_map
[
'callbacks_on_reload'
]:
try
:
c
.
callback
()
except
Exception
:
report_exception
(
c
,
'callbacks_on_reload'
)
def
model_loaded_callback
(
sd_model
):
for
c
in
callback_map
[
'callbacks_model_loaded'
]:
try
:
...
...
@@ -195,6 +203,9 @@ 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_before_reload
(
callback
):
"""register a function to be called just before the server reloads."""
add_callback
(
callback_map
[
'callbacks_on_reload'
],
callback
)
def
on_model_loaded
(
callback
):
"""register a function to be called when the stable diffusion model is created; the model is
...
...
webui.py
View file @
0c8825b2
...
...
@@ -108,6 +108,7 @@ def wait_on_server(demo=None):
time
.
sleep
(
0.5
)
modules
.
script_callbacks
.
app_polling_callback
(
None
,
demo
)
if
shared
.
state
.
need_restart
:
modules
.
script_callbacks
.
app_reload_callback
(
None
,
demo
)
shared
.
state
.
need_restart
=
False
time
.
sleep
(
0.5
)
demo
.
close
()
...
...
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