Issue2412

classification
Title: Jython does not terminate process when used with loadwatch
Type: behaviour Severity: normal
Components: None Versions: Jython 2.7, Jython 2.5
Milestone:
process
Status: open Resolution:
Dependencies: Superseder:
Assigned To: Nosy List: iMichka, zyasoft
Priority: Keywords:

Created on 2015-10-20.10:03:22 by iMichka, last changed 2016-01-22.13:26:43 by iMichka.

Messages
msg10364 (view) Author: Michka (iMichka) Date: 2015-10-20.10:03:21
Hi

I was not able to find any bug related to this problem. The bug was probably introduced between jython 2.5.1 and 2.5.2,
(and is also present on jython 2.5.3). I am working on Ubuntu 12.04.

If I try to execute a simple python file (test.py) containing for example a single line like "a = 1" with loadwatch,
the process never ends.

With jython 2.5.1:

popoff@michka:~$ loadwatch -h 10 -- jython-2.5.1 test.py
Tue Oct 20 11:50:52 2015 (3839): child 3840 finished.
Tue Oct 20 11:51:02 2015: no child process, exiting.


With jython 2.5.2 and 2.5.3 the process never ends (nothing happens):

popoff@michka:~$ loadwatch -h 10 -- jython-2.5.3 test.py
(hangs indefinitely)


The process table looks like this (gotten with ps xf):

 3749 pts/6    Ss     0:00  \_ bash
 3927 pts/6    S+     0:00  |   \_ loadwatch -h 10 -- jython-2.5.3 test.py
 3928 pts/6    T      0:00  |       \_ loadwatch -h 10 -- jython-2.5.3 test.py
 3929 pts/6    Tl     0:00  |           \_ /opt/java6/lib/jvm/java-6/bin/java -Djava.library.path=/usr/lib/jni -Dpython.home=/usr/share/jython-2.5.3 -Dpython.path=/usr/lib/site-python:/usr/share/jython-2.5.3/Lib -Dpython.executable=/usr/bin/jython-2.5.3 -Dpython.cachedir=/home/popoff/.jython-2.5.3-cache -Dpython.console=org.python.util.ReadlineConsole -Dpython.console.readlinelib=Editline org.python.util.jython test.py

Maybe this is a known problem ? I can not test jython 2.7 for the moment but I could built it from source to give it a try.
msg10369 (view) Author: Jim Baker (zyasoft) Date: 2015-10-21.22:26:26
You might try using jython --print to get the specific java command line options used for your program by the Jython launcher; then try using loadwatch with that and see if the process properly terminates.

Also Jython 2.7.0 changed the launcher to use CPython, so that's worth trying as well.
msg10404 (view) Author: Michka (iMichka) Date: 2015-10-29.10:05:12
Hi

By testing with --print, you mean:
loadwatch -h 10 -- jython-2.5.3 --print

This works, the help is printend and the process terminates. So this is only happening when a file is read.

I tested with jython 2.7.0 and it is also stuck:
loadwatch -h 10 -- /usr/lib/jvm/java-8-openjdk-amd64/bin/java -jar jython-standalone-2.7.0.jar test.py

15103 pts/5    Ss     0:00  \_ bash
16211 pts/5    S+     0:00  |   \_ loadwatch -h 10 -- /usr/lib/jvm/java-8-openjdk-amd64/bin/java -jar jython-standalone-2.7.0.jar test.py
16212 pts/5    T      0:00  |       \_ loadwatch -h 10 -- /usr/lib/jvm/java-8-openjdk-amd64/bin/java -jar jython-standalone-2.7.0.jar test.py
16213 pts/5    Tl     0:01  |           \_ /usr/lib/jvm/java-8-openjdk-amd64/bin/java -jar jython-standalone-2.7.0.jar test.py
16238 pts/5    T      0:00  |               \_ sh -c stty -icanon min 1 -icrnl -inlcr -ixon < /dev/tty
16239 pts/5    T      0:00  |                   \_ stty -icanon min 1 -icrnl -inlcr -ixon
msg10668 (view) Author: Michka (iMichka) Date: 2016-01-22.09:45:34
Hi. I just tested again with version 2.7.1b2 and the problem is still there.

I wanted to make a git bisect between 2.5.1 and 2.5.2, but it is very difficult because the dependencies have changed a lot and I am even not able to recompile these old Jython versions (even in a clean docker container with the corresponding debian/ubuntu).

I'll try to have a look at the jython source code itself, are there some files I should start with (if you have in idea were the problem could be). Thanks in advance.
msg10669 (view) Author: Michka (iMichka) Date: 2016-01-22.13:26:42
I was able to compile the master branch, and gave it a shot.

Using some debug print statements, I found that Jython is stuck in JLineConsole, when creating a new ConsoleReader(). Even when using the ConsoleReader constructor without arguments, Jython is stuck. This probably means that the bug is in Jline.

https://github.com/jythontools/jython/blob/master/src/org/python/util/JLineConsole.java#L107

Using a different console (with -Dpython.console=org.python.core.PlainConsole at start) works with loadwatch. This is a first alternative which allows to work with Jython and loadwatch.

I will continue to investigate what is going on inside JLine.
History
Date User Action Args
2016-01-22 13:26:43iMichkasetmessages: + msg10669
2016-01-22 09:45:34iMichkasetmessages: + msg10668
2015-10-29 10:05:12iMichkasetmessages: + msg10404
versions: + Jython 2.7
2015-10-21 22:26:26zyasoftsetnosy: + zyasoft
messages: + msg10369
2015-10-20 10:03:22iMichkacreate