views:

333

answers:

1

I'm trying to control the execution of a Jython script from within Java and executed through a call to PythonInterpreter.exec(). The script contains calls to classes defined in Java. I'll call these classes "commands" for the discussion here. The commands can also be run on a different machine via RMI.

Since the commands take a while to complete, I want to check the progress of the commands' execution on the caller side, like at what percentage of the execution is complete. I can provide a getProgress() method to the classes but accessing this method seems to be impossible to do because PythonInterpreter doesn't allow the caller access to the command object running inside it.

Any ideas on how to do this?

+2  A: 

my 0.10 Eur : (ist not easy)

Build a Factory as descripted in

http://wiki.python.org/jython/JythonMonthly/Articles/September2006/1

and a Java-Interface that represents a script-class (IJScript) (including run() and getProgress() methods)

your scripts should then look like this:

class xyscript(IJScript) :

def __init__(self) :
   ...
def run(self) :
   ...
def getProgress(self) :
   ....

run your scripts in accessing the Interface IJScript (the Java Interface) (look at the employee example)

Blauohr