java crashes in python thread

Easeway easeway.hu at sap.com
Mon Feb 28 22:42:53 EST 2005


I use os.system invoking java VM, when running in python thread, 
the java application crashes.  But it works properly when thread is
not used.

Has any body come across with this problem?

Python 2.3.3
J2SDK 1.4.2_05
SuSE Linux Enterprise Server 9

The following is source file:
#!/usr/bin/env python

import os, sys, threading

class ThreadTask(threading.Thread) :

    def __init__(self, shellcmd) :
        threading.Thread.__init__(self)
        self.command = shellcmd

    def isStopped(self) :
        self.join(0.01)
        return not self.isAlive()

    def run(self) :
        os.system(self.command)
    
def test() :
    commands = [
                    "/usr/lib/java/bin/javac",
                    "/usr/lib/java/bin/java",
               ]
    tasks = []    
    for a in commands :
        tasks.append(ThreadTask(a))
    
    for a in tasks :
        a.start()
        
    endcnt = 0
    while endcnt < len(tasks) :
        endcnt = 0
        for a in tasks :
            if a.isStopped() : endcnt += 1
    print("DONE")

test()




More information about the Python-list mailing list