Skip to content

Commit dd2108f

Browse files
committed
fix: should invoke callback as well in api only mode
1 parent 95c6308 commit dd2108f

File tree

2 files changed

+4
-1
lines changed

2 files changed

+4
-1
lines changed

modules/script_callbacks.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
import traceback
33
from collections import namedtuple
44
import inspect
5+
from typing import Optional
56

67
from fastapi import FastAPI
78
from gradio import Blocks
@@ -62,7 +63,7 @@ def clear_callbacks():
6263
callbacks_image_saved.clear()
6364
callbacks_cfg_denoiser.clear()
6465

65-
def app_started_callback(demo: Blocks, app: FastAPI):
66+
def app_started_callback(demo: Optional[Blocks], app: FastAPI):
6667
for c in callbacks_app_started:
6768
try:
6869
c.callback(demo, app)

webui.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,8 @@ def api_only():
114114
app.add_middleware(GZipMiddleware, minimum_size=1000)
115115
api = create_api(app)
116116

117+
modules.script_callbacks.app_started_callback(None, app)
118+
117119
api.launch(server_name="0.0.0.0" if cmd_opts.listen else "127.0.0.1", port=cmd_opts.port if cmd_opts.port else 7861)
118120

119121

0 commit comments

Comments
 (0)