lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


On 09.03.22 22:05, John W wrote:
> I have a lua VM running a task, and in a bad case, that task could
> have an infinite loop.
> I would like to fail such a task, after some timeout.

You may have a look at mtint ( https://github.com/osch/lua-mtint#mtint ),
especially at Example 3 ( https://github.com/osch/lua-mtint#example-3 ).

With mtint it is possible to interrupt a concurrently running Lua thread from
another thread and in the interrupt handler in the interrupted thread you can
investigate variables and decide if you want to continue or to abort etc.
However this approach requires preemptive threads: mtint works with any multi
threading scenario, the examples are using lua-llthreads2.

Best regards,
Oliver