# HG changeset patch # User Matthew Wild # Date 1700590369 0 # Node ID 5206314d6c70c67dbadd948fc573f37e5e41ec9c # Parent 49ecfb070240d4d2b914514f6adecf9bf8aa5367 util.async: Improve debug logging in a few places Knowing the state of the coroutine as well as the runner state can be helpful. diff -r 49ecfb070240 -r 5206314d6c70 util/async.lua --- a/util/async.lua Tue Nov 21 18:11:40 2023 +0000 +++ b/util/async.lua Tue Nov 21 18:12:49 2023 +0000 @@ -46,7 +46,9 @@ local function runner_continue(thread) -- ASSUMPTION: runner is in 'waiting' state (but we don't have the runner to know for sure) if coroutine.status(thread) ~= "suspended" then -- This should suffice - log("error", "unexpected async state: thread not suspended"); + log("error", "unexpected async state: thread not suspended (%s, %s)", thread, coroutine.status(thread)); + -- Fetching the traceback is likely to *crash* if a C library is calling us while suspended + --log("error", "coroutine stack: %s", debug.traceback()); return false; end local ok, state, runner = coroutine.resume(thread); @@ -198,6 +200,7 @@ -- Loop through queue items, and attempt to run them for i = 1,n do local queued_input = q[i]; + self:log("Resuming thread with new item [%s]", thread); local ok, new_state = coroutine.resume(thread, queued_input); if not ok then -- There was an error running the coroutine, save the error, mark runner as ready to begin again @@ -225,7 +228,7 @@ -- Runner processed all items it can, so save current runner state self.state = state; if err or state ~= self.notified_state then - self:log("debug", "changed state from %s to %s", self.notified_state, err and ("error ("..state..")") or state); + self:log("debug", "changed state from %s to %s [%s %s]", self.notified_state, err and ("error ("..state..")") or state, self.thread, self.thread and coroutine.status(self.thread)); if err then state = "error" else