problem with jpype and thread

silkenpy ali_292000 at yahoo.com
Wed Feb 6 01:42:08 EST 2008



I start using thread with simple example but now I have some problem. 


================PYTHON is the best===================

import threading 
import time 
from jpype import * 

def sleepFunction(): 
    print"ya ali" 
    classpath = "-Djava.class.path=praat.jar" 
    startJVM(getDefaultJVMPath(),"-ea",classpath) 
    Formant=JPackage("praat").Formant 
    s=Formant("iia-001-000.Formant") 
    w=s.getF2_frequency() 
    print w 
    shutdownJVM() 

thread1 = threading.Thread( target=sleepFunction) 
thread1.start() 

#thread2 = threading.Thread( target=sleepFunction) 
#thread2.start() 

in this case it works very well and output is 

ya ali 
2456.8025 
JVM activity report     : 
        classes loaded       : 20 
JVM has been shutdown 

BUT if I uncomment thread2 part  I have this result : 


ya ali 
ya ali 
Exception in thread Thread-2: 
Traceback (most recent call last): 
  File "D:\Python25\lib\threading.py", line 460, in __bootstrap 
    self.run() 
  File "D:\Python25\lib\threading.py", line 440, in run 
    self.__target(*self.__args, **self.__kwargs) 
  File
"C:\Downloads\_extracted\py_threading.zip.extracted\py_threading\sle.py", 
 line 18, in sleepFunction 
    jpype.startJVM(jpype.getDefaultJVMPath(),"-ea",classpath) 
  File "D:\Python25\Lib\site-packages\jpype\_core.py", line 43, in startJVM 
    _jpype.startup(jvm, tuple(args), True) 
RuntimeError: Unable to start JVM at src/native/common/jp_env.cpp:54 

Exception in thread Thread-1: 
Traceback (most recent call last): 
  File "D:\Python25\lib\threading.py", line 460, in __bootstrap 
    self.run() 
  File "D:\Python25\lib\threading.py", line 440, in run 
    self.__target(*self.__args, **self.__kwargs) 
  File
"C:\Downloads\_extracted\py_threading.zip.extracted\py_threading\sle.py", 
 line 18, in sleepFunction 
    jpype.startJVM(jpype.getDefaultJVMPath(),"-ea",classpath) 
  File "D:\Python25\Lib\site-packages\jpype\_core.py", line 43, in startJVM 
    _jpype.startup(jvm, tuple(args), True) 
RuntimeError: Unknown Exception 


Really Thanks for your supporting 
-- 
View this message in context: http://www.nabble.com/problem-with-jpype-and-thread-tp15306178p15306178.html
Sent from the Python - python-list mailing list archive at Nabble.com.




More information about the Python-list mailing list