mirror of
https://github.com/AUTOMATIC1111/stable-diffusion-webui.git
synced 2024-12-21 07:30:02 +08:00
Add polling callback
This commit is contained in:
parent
685f9631b5
commit
1742c04bab
@ -63,6 +63,7 @@ callback_map = dict(
|
||||
callbacks_cfg_denoiser=[],
|
||||
callbacks_before_component=[],
|
||||
callbacks_after_component=[],
|
||||
callbacks_on_polling=[],
|
||||
)
|
||||
|
||||
|
||||
@ -78,6 +79,12 @@ def app_started_callback(demo: Optional[Blocks], app: FastAPI):
|
||||
except Exception:
|
||||
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):
|
||||
for c in callback_map['callbacks_model_loaded']:
|
||||
@ -184,6 +191,11 @@ def on_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):
|
||||
"""register a function to be called when the stable diffusion model is created; the model is
|
||||
passed as an argument"""
|
||||
|
Loading…
Reference in New Issue
Block a user