Hi,
I use ScriptingContainer on client application to add customize
behavior by user.
Sometimes user makes mistake. So I think they’d like to terminate
running script.
I’m looking for the API to terminate the script. But I can’t find it.
Is there a way to terminate running embedded script?
Regards,
–
Hiroki K.
[email protected]
It’s not something we’ve exposed, but the Ruby ways would usually work
(i.e. Thread#raise or Thread#stop). I don’t encourage their use, but
they do work in JRuby.
Perhaps this is something we could expose through RedBridge? Perhaps
with a query API as well?
if (container.isScriptInterruptible()) {
long limit = 10000;
JRubyFuture jfuture = container.runScriptAsyncOrWhatever();
jfuture.getWithTimeout(limit);
if (jfuture.result == null) {
jfuture.terminate();
}
}
Just brainstorming based on similar APIs in java.util.concurrent.
On Sun, Dec 12, 2010 at 4:13 AM, Charles Oliver N.
[email protected] wrote:
It’s not something we’ve exposed, but the Ruby ways would usually work
(i.e. Thread#raise or Thread#stop). I don’t encourage their use, but
they do work in JRuby.
Perhaps this is something we could expose through RedBridge? Perhaps
with a query API as well?
Probably. At least. we need a new method to stop running script.
if (container.isScriptInterruptible()) {
long limit = 10000;
JRubyFuture jfuture = container.runScriptAsyncOrWhatever();
jfuture.getWithTimeout(limit);
if (jfuture.result == null) {
jfuture.terminate();
}
}
Just brainstorming based on similar APIs in java.util.concurrent.
Agreed. java.util.concurrent has a good API to look at for designing
this kind of API. Or, if it is on our ThreadSafe context,
ThreadLocal#remove() method might work. In this case,
isScriptInterruptible() method will just check the context model.
Perhaps, ScriptingContainer will have a stop() method. The
implementation will be simple. However, java.util.concurrent style
looks more controllable and reliable.
-Yoko