kingluo commented on code in PR #9909:
URL: https://github.com/apache/apisix/pull/9909#discussion_r1275673613


##########
apisix/core/config_etcd.lua:
##########
@@ -188,9 +190,43 @@ local function run_watch(premature)
 
         ::watch_event::
         while true do
-            local res, err = res_func()
-            if log_level >= NGX_INFO then
-                log.info("res_func: ", inspect(res))
+            local res
+            local sema, err = semaphore.new()
+            if not sema then
+                log.error("create sema failed", err)
+                goto watch_event
+            end
+
+            local get_res_th = ngx_thread_spawn(function ()
+                res, err = res_func()
+                if log_level >= NGX_INFO then
+                    log.info("res_func: ", inspect(res))
+                end
+                sema:post()
+            end)
+
+            local check_worker_th = ngx_thread_spawn(function ()
+                while not exiting() do
+                    ngx_sleep(0.1)
+                end
+                sema:post()
+            end)
+
+            local _, sem_err = sema:wait(opts.timeout + 10)

Review Comment:
   Could we use ngx.thread.wait instead of sema?



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to