# HG changeset patch # User Matthew Wild # Date 1592120972 -3600 # Node ID 69a4b0e3565f7c9cbd08f2c039e2c80a4334eb3e # Parent ad5e373b14195cd08333ac451d731ec21571bc3c util.async: Call coroutine.close() on dead threads (Lua 5.4) diff -r ad5e373b1419 -r 69a4b0e3565f util/async.lua --- a/util/async.lua Sat Jun 13 14:40:41 2020 +0200 +++ b/util/async.lua Sun Jun 14 08:49:32 2020 +0100 @@ -53,7 +53,7 @@ return false; end call_watcher(runner, "error", debug.traceback(thread, err)); - runner.state, runner.thread = "ready", nil; + runner.state = "ready"; return runner:run(); elseif state == "ready" then -- If state is 'ready', it is our responsibility to update runner.state from 'waiting'. @@ -159,6 +159,10 @@ local q, thread = self.queue, self.thread; if not thread or coroutine.status(thread) == "dead" then + --luacheck: ignore 143/coroutine + if coroutine.close then + coroutine.close(thread); + end self:log("debug", "creating new coroutine"); -- Create a new coroutine for this runner thread = runner_create_thread(self.func, self);