problem with jpype and thread

S

silkenpy

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,576
Members
45,054
Latest member
LucyCarper

Latest Threads

Top