nvim-lua / plenary.nvim

plenary: full; complete; entire; absolute; unqualified. All the lua functions I don't want to write twice.
MIT License
2.69k stars 284 forks source link

How to kill a in-flight curl job? #547

Closed sunn4room closed 10 months ago

sunn4room commented 10 months ago
local curl = require("plenary.curl")
-- long time to callback
local handler = curl.post("https://tianqi.aminer.cn/api/v2/multilingual_code_generate_adapt", {
    body = vim.fn.json_encode({
        prompt = "# print hello world\n",
        n = 3,
        lang = "Python",
        apikey = "68cf004321e94b47a91c2e45a8109852",
        apisecret = "e82b86a16f9d471ab215f653060310e3",
    }),
    headers = {
        content_type = "application/json",
    },
    callback = vim.schedule_wrap(function(res)
        vim.notify(vim.inspect(res))
    end),
})
-- want to kill the in-flight curl job
handler:shutdown() -- get error
-- how to kill ?

Help. Please...