mirror of
https://github.com/AUTOMATIC1111/stable-diffusion-webui.git
synced 2026-01-06 01:02:02 -08:00
Add a callback called before reloading the server
This commit is contained in:
parent
1742c04bab
commit
0c8825b2be
2 changed files with 13 additions and 1 deletions
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue