mirror of
https://github.com/leejet/stable-diffusion.cpp.git
synced 2026-11-28 19:16:33 +00:00
POST /sdcpp/v1/jobs/{id}/cancel used to answer 409 for a job that had
started. It now tells the library to stop and waits for the job to end:
200 with the cancelled job as soon as it has ended, or 202 with the job and
"cancel_requested": true when it is still stopping after ?wait= seconds
(0 to 60, default 10; 0 answers at once). Repeating the call is harmless,
and GET /sdcpp/v1/jobs/{id} shows the pending request. /capabilities now
reports cancel_generating as true.
The request belongs to the job: ContextKeeper::run() takes a CancelToken
and registers it, with the context, only while that job's attempt is
executing. A stop for one job can therefore never reach another request
(including a synchronous /sdapi one), a job cancelled before it reaches the
context generates nothing, and the context can be released or rebuilt
without cancel() ever touching a context that is gone.
The library forgets a stop request when a generation begins, so a request
that arrives a moment earlier would be lost. The route repeats it every
100 ms until the job ends.
A cancelled run is neither a failure nor a reason to step down: it does not
reload the model, does not touch last_error, and has its own counter,
counters.cancelled in /health. When a stop and a recoverable failure meet,
the stop wins and the model is not reloaded for a request nobody waits for.
Checked on a real sd-server with a CPU build and a synthetic model: stop of
a running job, repeated stop, queued job, job already finished, unknown id,
wait=0, invalid wait, and the next job on the same context. Tests and
documentation follow in separate commits.
Claude-Session: https://claude.ai/code/session_01EhZzDBkuuMp1jBf4WtEySC
|
||
|---|---|---|
| .. | ||
| cli | ||
| common | ||
| server | ||
| CMakeLists.txt | ||