feat(server): support cancellation of running generation jobs (#2190)

This commit is contained in:
leejet authored and GitHub committed 2026-10-23 00:24:56 +08:00
1 parent deaeed6a2f
commit e779d4f149
5 files changed
+78 -21

No files matched your search

+7 -6
View File
@@ -206,7 +206,7 @@ static json make_img_gen_features_json() {
{"hires", true},
{"cache", true},
{"cancel_queued", true},
{"cancel_generating", false},
{"cancel_generating", true},
{"preview", true},
};
}
@@ -221,7 +221,7 @@ static json make_vid_gen_features_json() {
{"vae_tiling", true},
{"cache", true},
{"cancel_queued", true},
{"cancel_generating", false},
{"cancel_generating", true},
{"preview", true},
};
}
@@ -380,8 +380,8 @@ static json make_capabilities_json(ServerRuntime& runtime) {
json top_level_defaults = json::object();
json top_level_output_formats = json::array();
json top_level_features = {
{"cancel_queued", true},
{"cancel_generating", false},
{"cancel_queued", true},
{"cancel_generating", true},
};
std::string current_mode = "";
if (supports_img) {
@@ -840,8 +840,9 @@ void register_sdcpp_api_endpoints(httplib::Server& svr, ServerRuntime& rt) {
}
if (job.status == AsyncJobStatus::Generating) {
res.status = 409;
res.set_content(R"({"error":"job is currently generating and cannot be interrupted yet"})", "application/json");
job.cancel_requested.store(true);
res.status = 200;
res.set_content(make_async_job_json(manager, job).dump(), "application/json");
return;
}