Skip to content

Commit 320bbb9

Browse files
committed
server: do not block when loading
1 parent 15bd894 commit 320bbb9

File tree

1 file changed

+10
-8
lines changed

1 file changed

+10
-8
lines changed

examples/server/main.cpp

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1080,7 +1080,7 @@ void start_server(SDParams params) {
10801080
bool updateCTX = false;
10811081
try {
10821082
std::string json_str = req.body;
1083-
updateCTX = parseJsonPrompt(json_str, &params);
1083+
updateCTX = parseJsonPrompt(json_str, &params);
10841084
} catch (json::parse_error& e) {
10851085
// assume the request is just a prompt
10861086
// LOG_WARN("Failed to parse json: %s\n Assuming it's just a prompt...\n", e.what());
@@ -1106,14 +1106,16 @@ void start_server(SDParams params) {
11061106

11071107
if (sd_ctx == NULL) {
11081108
printf("Loading sd_ctx\n");
1109-
json task_json = json::object();
1110-
task_json["status"] = "Loading";
1111-
task_json["data"] = json::array();
1112-
task_json["step"] = -1;
1113-
task_json["eta"] = "?";
1109+
{
1110+
json task_json = json::object();
1111+
task_json["status"] = "Loading";
1112+
task_json["data"] = json::array();
1113+
task_json["step"] = -1;
1114+
task_json["eta"] = "?";
11141115

1115-
std::lock_guard<std::mutex> results_lock(results_mutex);
1116-
task_results[task_id] = task_json;
1116+
std::lock_guard<std::mutex> results_lock(results_mutex);
1117+
task_results[task_id] = task_json;
1118+
}
11171119

11181120
sd_ctx = new_sd_ctx(params.ctxParams.model_path.c_str(),
11191121
params.ctxParams.clip_l_path.c_str(),

0 commit comments

Comments
 (0)