Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closing ScriptingContainer after calling runScriptlet? #5778

Open
taimoorgit opened this issue Jun 28, 2019 · 2 comments

Comments

Projects
None yet
2 participants
@taimoorgit
Copy link

commented Jun 28, 2019

ScriptingContainer ruby = new ScriptingContainer(LocalVariableBehavior.PERSISTENT);

new Thread() {
                @Override
                public void run() {
                    try {
                        Thread.sleep(3 * 1000); // Timeout
                        System.out.println("Timeout passed.");
                        ruby.terminate(); // This has no effect?
                    } catch (Exception e) {
                        e.printStackTrace();
                    }
                }
            }.start();

Object output = ruby.runScriptlet(scriptWithAnInfiniteLoop);
ruby.terminate(); // Terminate without timeout

How can I make it so that ruby.terminate() closes runScriptlet? It keeps running despite ruby.terminate() being called. Is there another function I should be using?

@taimoorgit

This comment has been minimized.

Copy link
Author

commented Jun 28, 2019

I suppose after my timeout code I could start a new thread that runs runScriptlet, since it runs on the main thread. 🤔

@kares kares added this to the Invalid or Duplicate milestone Jul 5, 2019

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.