problem with jpype and thread

2008-02-05 Thread 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 
-- 
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.

-- 
http://mail.python.org/mailman/listinfo/python-list


Please help help ..... for threading

2008-02-14 Thread silkenpy

Hi, 
please help me to find a solution to run this program correctlly or tell me
my basic mistake. 

import thread 
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() 


for i in range(1): 
thread.start_new_thread(sleepFunction, ()) 
time.sleep(1) 
print "goodbye!" 


The result is 
ya ali 
ya ali 
Unhandled exception in thread started by  
Traceback (most recent call last): 
  File
"C:\Downloads\_extracted\py_threading.zip.extracted\py_threading\sle.py", 
 line 19, in sleepFunction 
startJVM(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 
Unhandled exception in thread started by  
Traceback (most recent call last): 
  File
"C:\Downloads\_extracted\py_threading.zip.extracted\py_threading\sle.py", 
 line 19, in sleepFunction 
startJVM(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 
goodbye! 

Thanks a lot. 
-- 
View this message in context: 
http://www.nabble.com/Please-help-help-.-for-threading-tp15492998p15492998.html
Sent from the Python - python-list mailing list archive at Nabble.com.

-- 
http://mail.python.org/mailman/listinfo/python-list