I'd like to be able to set hooks to do stuff like rate limiting the execution of Lua code. Production use cases:
running untrusted code submitted from users (stop infinite loops)
pre-empting a CPU-heavy lua script in an async event loop
And then there's the typical debugging tasks, but this isn't as important for me.
I think I can get the last one by using debug.sethook within a Lua script, but I think the first two would require support from hlua itself.
Ideally, this would allow resuming a task that's been pre-empted (to solve the second use case).
Is this something you're interested in supporting? If so, do you anticipate any problems in implementation? I may be able to contribute something, but I'd like direction before getting started.
EDIT: It looks like I don't need support from hlua for the first use-case, and can get a pretty decent result by running all user code in a closure. I'm not sure about the second though.
I'd like to be able to set hooks to do stuff like rate limiting the execution of Lua code. Production use cases:
And then there's the typical debugging tasks, but this isn't as important for me.
I think I can get the last one by using
debug.sethook
within a Lua script, but I think the first two would require support fromhlua
itself.Ideally, this would allow resuming a task that's been pre-empted (to solve the second use case).
Is this something you're interested in supporting? If so, do you anticipate any problems in implementation? I may be able to contribute something, but I'd like direction before getting started.
EDIT: It looks like I don't need support from
hlua
for the first use-case, and can get a pretty decent result by running all user code in a closure. I'm not sure about the second though.