🗑️ LuatOS bug 已修复, 不再使用 sys.waitUntil 判断 http 请求是否超时

This commit is contained in:
Mizore 2023-02-09 18:48:06 +08:00
parent ddf0943049
commit 87e441a1d2

View File

@ -23,16 +23,11 @@ function util_http.fetch(timeout, method, url, headers, body)
util_netled.blink(50, 50) util_netled.blink(50, 50)
sys.taskInit(
function()
log.debug("util_http.fetch", "开始请求", "id:", id) log.debug("util_http.fetch", "开始请求", "id:", id)
res_code, res_headers, res_body = http.request(method, url, headers, body, opts).wait() res_code, res_headers, res_body = http.request(method, url, headers, body, opts).wait()
log.debug("util_http.fetch", "请求结束", "id:", id, "code:", res_code) log.debug("util_http.fetch", "请求结束", "id:", id, "code:", res_code)
sys.publish(id)
end if res_code == -8 then
)
local result = sys.waitUntil(id, timeout + 1000 * 25)
if not result or res_code == -8 then
log.warn("util_http.fetch", "请求超时", "id:", id) log.warn("util_http.fetch", "请求超时", "id:", id)
end end