Skip to content

Commit 2eae770

Browse files
feat(webui): support concurrency
1 parent 366a65e commit 2eae770

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

webui/app.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@
77
import gradio as gr
88

99
from gradio_i18n import Translate, gettext as _
10+
from numba.cuda import shared
11+
1012
from test_api import test_api_connection
1113
from cache_utils import setup_workspace, cleanup_workspace
1214
from count_tokens import count_tokens
@@ -180,9 +182,6 @@ def sum_tokens(client):
180182
json.dump(output_data, tmpfile, ensure_ascii=False)
181183
output_file = tmpfile.name
182184

183-
# Clean up workspace
184-
cleanup_workspace(graph_gen.working_dir)
185-
186185
synthesizer_tokens = sum_tokens(graph_gen.synthesizer_llm_client)
187186
trainee_tokens = sum_tokens(graph_gen.trainee_llm_client) if config['if_trainee_model'] else 0
188187
total_tokens = synthesizer_tokens + trainee_tokens
@@ -217,6 +216,10 @@ def sum_tokens(client):
217216
except Exception as e: # pylint: disable=broad-except
218217
raise gr.Error(f"Error occurred: {str(e)}")
219218

219+
finally:
220+
# Clean up workspace
221+
cleanup_workspace(graph_gen.working_dir)
222+
220223

221224
with (gr.Blocks(title="GraphGen Demo", theme=gr.themes.Glass(),
222225
css=css) as demo):
@@ -476,4 +479,5 @@ def sum_tokens(client):
476479
)
477480

478481
if __name__ == "__main__":
482+
demo.queue(api_open=False, default_concurrency_limit=10)
479483
demo.launch(server_name='0.0.0.0')

0 commit comments

Comments
 (0)