Issue1655

classification
Title: logging module work for only one instance of jython
Type: behaviour Severity: major
Components: Core, Library Versions: 2.5.0
Milestone:
process
Status: closed Resolution:
Dependencies: Superseder:
Assigned To: Nosy List: root@127.0.0.1, zyasoft
Priority: Keywords:

Created on 2010-09-22.17:51:27 by root@127.0.0.1, last changed 2010-10-15.01:17:47 by zyasoft.

Messages
msg6086 (view) Author: root (root@127.0.0.1) Date: 2010-09-22.17:51:25
I have a tomcat webapp that use Jython as scripting language (thank you!).

I run python script periodically and I use logging to save debug output to syslog.

When I start tomcat and execute the first time a python script that use logging, it work perfectly.
If I try to run the same script again, nothing is sent to the log handler anymore.
I tried all log level on many different log handler.
If I use an other script that use logging too, nothing appears.
I need to restart tomcat to be able to send log again.

If I change logging handler, from let say, syslog to a rotating file WITHOUT a tomcat restart. The handler will create the file, but nothing will be written into the file.
Like if a sub part of logging is impacted.

I asked m developers to use Jython in a way that everything is reset at each invocation of jython.
It's plugged into the webapp this way:

public void executeScriptFile(File scriptFile, Map<String, Object> parameterMap, OutputStream stdoutOutputStream, OutputStream stderrOutputStream) throws Exception {
         PythonInterpreter pythonInterpreter = new PythonInterpreter(); 
         pythonInterpreter.setErr(stderrOutputStream);
         pythonInterpreter.setOut(stdoutOutputStream);

         // I think there is some constant not shown here
         // but I think you can understand what they wanted to do here
         for (Map.Entry<String, Object> entry : parameterMap.entrySet()) {
           if (!entry.getKey().equals(PYTHON_SCRIPT_FILE_NAME_PARAMETER)) {
             pythonInterpreter.set(entry.getKey(), entry.getValue());
           }
         }
         pythonInterpreter.execfile(scriptFile.getPath());
         pythonInterpreter.cleanup();
         PyStringMap pyStringMap = (PyStringMap)pythonInterpreter.getLocals();
         pyStringMap.clear();
       }

I do not know if the problem is in the way jython is invoked or in the library itself.
Sorry, I'm a python developer, not a Java developer, I did not wrote the java part, so I might be confused about the java specific stuff.
msg6120 (view) Author: Jim Baker (zyasoft) Date: 2010-10-03.05:39:20
You should create a new PySystemState and pass it to the constructor of PythonInterpreter. This should enable you to have a separate instance of the logging module.
msg6167 (view) Author: Jim Baker (zyasoft) Date: 2010-10-15.01:17:46
Closing this issue as a support issue.
History
Date User Action Args
2010-10-15 01:17:47zyasoftsetstatus: open -> closed
messages: + msg6167
2010-10-03 05:39:21zyasoftsetnosy: + zyasoft
messages: + msg6120
2010-09-22 17:51:27root@127.0.0.1create