[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: Nonblocking script execution
- From: Alexander Gladysh <agladysh@...>
- Date: Tue, 24 Feb 2009 23:42:06 +0300
On Tue, Feb 24, 2009 at 6:08 PM, Jeff Pohlmeyer
<yetanothergeek@gmail.com> wrote:
> On Tue, Feb 24, 2009 at 7:04 AM, Alexander Gladysh <agladysh@gmail.com> wrote:
>> Say, I set instruction count hook. If it is triggered (and some
>> condition is met -- given time passed, for example), I need to kill
>> Lua state. How do I kill it most gracefully? I'd like all allocated
>> resources to be freed. (I think it would be perfect to be able to
>> imitate conventional runtime error raised from the hook point. Not
>> sure if this is achievable though...)
> I have an application that does this,
> from inside the debug hook callback:
> if (timeout) {
> lua_pushstring(L, "Script timeout.");
> lua_error(L);
> }
> and it *seems* to work fine, but I'm no expert...
I see this is a popular solution. Thank you everyone who answered my question!
Can any Lua internals expert confirm that this is safe? Can
instruction count debug hook get called in the middle of something
sensitive?
I would settle for positive answer covering "current implementation",
but it would be great to have a legal way to terminate Lua state (or
trigger Lua error) from the hook.
Alexander.