任务管理
取消任务
POST /v1/tasks//cancel — 取消排队中的任务
POST
/
v1
/
tasks
/
{task_id}
/
cancel
取消任务
curl --request POST \
--url https://www.qingbo.dev/v1/tasks/{task_id}/cancelimport requests
url = "https://www.qingbo.dev/v1/tasks/{task_id}/cancel"
response = requests.post(url)
print(response.text)const options = {method: 'POST'};
fetch('https://www.qingbo.dev/v1/tasks/{task_id}/cancel', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));package main
import (
"fmt"
"net/http"
"io"
)
func main() {
url := "https://www.qingbo.dev/v1/tasks/{task_id}/cancel"
req, _ := http.NewRequest("POST", url, nil)
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://www.qingbo.dev/v1/tasks/{task_id}/cancel")
.asString();取消一个处于
queued 状态的任务,配额自动退还。
只有
queued 状态的任务可以取消。processing 状态的任务已经开始处理,无法取消——
此时返回 HTTP 400(code: task_not_cancellable)。队列流转是秒级的,取消窗口很小,
调用方应兜住 400 的情况。已取消的任务查询时 cost 为 0(配额已退还)。响应
{
"task_id": "task_xxx",
"status": "cancelled",
"refunded": true,
"refunded_quota": 50000
}
| 字段 | 说明 |
|---|---|
refunded | 是否已退还配额 |
refunded_quota | 退还的配额数量 |
⌘I
取消任务
curl --request POST \
--url https://www.qingbo.dev/v1/tasks/{task_id}/cancelimport requests
url = "https://www.qingbo.dev/v1/tasks/{task_id}/cancel"
response = requests.post(url)
print(response.text)const options = {method: 'POST'};
fetch('https://www.qingbo.dev/v1/tasks/{task_id}/cancel', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));package main
import (
"fmt"
"net/http"
"io"
)
func main() {
url := "https://www.qingbo.dev/v1/tasks/{task_id}/cancel"
req, _ := http.NewRequest("POST", url, nil)
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://www.qingbo.dev/v1/tasks/{task_id}/cancel")
.asString();