Skip to content

Commit

Permalink
Improve usefulness of debug.traceback in scheduler's errorfunc
Browse files Browse the repository at this point in the history
  • Loading branch information
Sainan authored and well-in-that-case committed Feb 4, 2025
1 parent 25ca70f commit 178e410
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion src/lschedulerlib.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,17 @@ return class
function add(t)
if type(t) ~= "thread" then
t = coroutine.create(t)
if self.errorfunc then
local f = t
t = coroutine.create(function()
local r = table.pack(xpcall(f, self.errorfunc))
if r[1] and r.n ~= 1 then
warn("Coroutine yielded values to scheduler. Discarding them.")
end
end)
else
t = coroutine.create(t)
end
end
table.insert(self.coros, t)
self:internalresume(t)
Expand Down

0 comments on commit 178e410

Please sign in to comment.