Resume a lua thread from rust and make it error inside lua #252
-
Hi, I'm trying to implement a task scheduler to mix and match blocking lua code with async rust code without doing busy polling on the lua side, but I can't figure out how to resume a lua thread while making it error inside of lua. I need to do this to let lua scripts handle errors that may happen in Rust code using Example code from the scheduler: A relevant test script is here and currently fails: |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 2 replies
-
I'm not sure that I fully understood the problem, do you have a smaller example? In general if you throw a error in lua coroutine, it unwinds the stack and there is no function to jump back: co = coroutine.create(function ()
coroutine.yield("1")
error("bla")
coroutine.yield("2")
end)
-- prints: true 1
print(coroutine.resume(co))
-- prints: false test.lua:3: bla
print(coroutine.resume(co))
-- prints: false cannot resume dead coroutine
print(coroutine.resume(co)) |
Beta Was this translation helpful? Give feedback.
I'm not sure that I fully understood the problem, do you have a smaller example?
In general if you throw a error in lua coroutine, it unwinds the stack and there is no function to jump back: