JPype在线程内部不起作用?

sai*_*eak 4 python java porting

我测试了一个简单的hello world line来测试JPype:

jpype.java.lang.System.out.println("hello world")

它在"主要"python程序的上下文中工作得很好.但是,在正在运行的线程的上下文中,我得到以下响应:

#
# A fatal error has been detected by the Java Runtime Environment:
#
#  SIGSEGV (0xb) at pc=0x00007f5272aeb226, pid=7888, tid=139991902578432
#
# JRE version: 7.0_01-b08
# Java VM: Java HotSpot(TM) 64-Bit Server VM (21.1-b02 mixed mode linux-amd64 compressed oops)
# Problematic frame:
# C  [_jpype.so+0x33226]  JPJavaEnv::FindClass(char const*)+0x36
#
# Failed to write core dump. Core dumps have been disabled. To enable core dumping, try "ulimit -c unlimited" before starting Java again
#
# An error report file with more information is saved as:
# /home/imedia/NTsvm/src/server/nlp/hs_err_pid7888.log
#
# If you would like to submit a bug report, please visit:
#   http://bugreport.sun.com/bugreport/crash.jsp
#
Aborted
Run Code Online (Sandbox Code Playgroud)

Mar*_*ner 9

引用JPype文档:

Python线程

在大多数情况下,基于操作系统级线程(即posix线程)的python线程可以正常工作.唯一要记住的是调用jpype.attachThreadToJVM()线程主体以使JVM可以从该线程中使用.对于您自己没有启动的线程,您可以打电话isThreadAttachedToJVM()进行检查.

HTH