Browse Source

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

Mizore 2 years ago
parent
commit
87e441a1d2
1 changed files with 5 additions and 10 deletions
  1. 5 10
      script/util_http.lua

+ 5 - 10
script/util_http.lua

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