I cannot reduce it to a simple example, because this is a large application. What I can send, if it offers some help, are the fragments of the principal involved classes:

This is a fragment of the class which executes a jython scripts and return the results

public class JPythonInterpreter implements Interpreter{

    protected PythonInterpreter pInterpreter;
    protected Object pMutex = new Object();

    protected Hashtable docsState;
    protected Vector clearedDocs;
    protected static LogHandler profileLog;

     * Constructor
    public JPythonInterpreter(){
        pInterpreter = new PythonInterpreter(null, new PySystemState());
        docsState = new Hashtable();
        clearedDocs = new Vector();

    public InterpreterResult evaluate(File file, Hashtable inputParameters,Vector outputVarNames){
        synchronized (pMutex){

            for(Enumeration inputNames = inputParameters.keys();inputNames.hasMoreElements();){
                String varName = inputNames.nextElement().toString();
                Object varValue = inputParameters.get(varName);
                // Si la variable es un documento, guarda su estado
            //Executes script
                pInterpreter.execfile(new FileInputStream(file));

                return new JPythonResults(pInterpreter,outputVarNames);
            catch(PyException pye){
                return null;
            catch(Exception e){
                return null;

The following is the method (into a singleton object) which returns a new instance of the mentioned interpreter

    public Interpreter getInterpreter(String lang) {
        if (lang != null) {
            try {
                Interpreter sInt = (Interpreter) Class.forName(
                        (String) interpreters.get(lang)).newInstance();
                String[] path = { (String) appObjects.get("ScriptsPath") };

                return (sInt);
            } catch (Exception e) {
        } else {
            return getInterpreter();

The following is a fragment of an implementation of a workflow condition, which gets an interpreter and executes it:

public class ScriptableCondition implements Condition{

    public boolean evaluate(Object invoker,Hashtable params)throws ConditionException{
        boolean result = evaluateWithReport(invoker,params).result();
        return result;

    public ConditionReport evaluateWithReport(Object invoker,Hashtable params)throws ConditionException{
          if (invoker != null)
        switch(type) {
            case CONST:
                return this.evaluateConst();
            case SCRIPT:
                return this.evaluateScript(params);
            case FILE:
                return this.evaluateFile(params);
                return this.evaluateFile(params);

     private void buildDocManager(Hashtable params){
        Context context = (Context)params.get("context");
          ScriptDocumentManager manager = new ScriptDocumentManager(context);
          params.put("scriptDocMgr", manager);

    protected ConditionReport evaluateConst(){
        return new ConditionReport(((expression.trim().equalsIgnoreCase("true"))||(expression.trim().equalsIgnoreCase("yes"))));

    protected ConditionReport evaluateScript(Hashtable params)throws ConditionException{
        Interpreter interpreter = AnalyteApplication.instance().getInterpreter(language);
        return processResult(interpreter.evaluate(expression,params,new String[] {RESULT_VAR_NAME,ERROR_CODE_VAR_NAME,ERROR_MESSAGE_VAR_NAME,MESSAGE_VAR_NAME}));

    protected ConditionReport evaluateFile(Hashtable params)throws ConditionException{
        File file = new File(AnalyteApplication.instance().getAppObject(AnalyteApplication.SCRIPTS_PATH)+ expression);
        Interpreter interpreter = AnalyteApplication.instance().getInterpreter(language);
        return processResult(interpreter.evaluate(file,params,new String[] {RESULT_VAR_NAME,ERROR_CODE_VAR_NAME,ERROR_MESSAGE_VAR_NAME,MESSAGE_VAR_NAME}));

    protected ConditionReport processResult(InterpreterResult results)throws ConditionException{

        String errorCode = results.getString(ERROR_CODE_VAR_NAME);
        String errorMessage = results.getString(ERROR_MESSAGE_VAR_NAME);
        if(((errorCode != null)&&(!errorCode.equals("")))||((errorMessage != null)&&(!errorMessage.equals(""))))
            throw new ConditionException(errorCode,errorMessage);

        boolean result = results.getBoolean(RESULT_VAR_NAME);
        String message = results.getString(MESSAGE_VAR_NAME);
        return new ConditionReport(result,message);

As I've mentioned in an earlier post, this works fine under "normal pressure", but when a burst of conditions must be evaluated at the same time, probably some execution will crash with errors that in my opinion, reveals that some interpreter instance has 'lost' some basic context information, I've never tried to read the implementation behind jython. Interesting is that I cannot reproduce these kind of errors when I use java objects implementing these scripts.

Thanks for your support,

         Juan Pablo

Charlie Groves <charlie.groves@gmail.com> escribió:
On 8/29/06, Juan Pablo Carlino wrote:
> I have read a post, in this mailing list which explains exactly the same
> problem I had during this time. The link is
> http://sourceforge.net/mailarchive/message.php?msg_id=10134445
> Saddly for me, the issue appears to continue open.

I can get the code from that message to throw exceptions in
jython-2.1, but not in 2.2 alpha 1. Could you(or Leo) reduce this
down to as simple an example as possible and submit a bug for it at
http://jython.org/bugs? If you do I'll try and track it down.


Preguntá. Respondé. Descubrí.
Todo lo que querías saber, y lo que ni imaginabas,
está en Yahoo! Respuestas (Beta).
Probalo ya!