I am currently using Jython as an embedded script interpreter which
executes scripts in independent threads. I would like to have a Java
method in the main thread be able to pause the progress of currently
running Jython scripts without requiring any additional coding in the
scripts themselves. I have three ways that I might approach this problem.
First and simplest, I could include checks in Java methods that are called
by scripts which would pause the application is paused and one of the
methods with this check is called. The main problem with this is that it
is not reliable. Not all scripts will necessarily call one of these
special methods and therefore may not yield. For example, imagine a while
loop that calls a built-in function. This code would continue until the
while loop is broken(which may be never).
Second, I could alter the actual Jython interpreter code to execute and
then check for paused conditions. I think that this might be a better
solution, but I would rather not have to wade through tons of code. I'm
worried that the compilation process makes this type of modification
Last, the application could add function calls to the code before it is
compiled. It would call application.waitUntilNotPaused() between each
I would be glad to hear any advice on the matter. It may be worth while to
investigate the second option if this is a feature others are interested
Thank you for your help.