I tested out a simple hello world line to test out JPype:
jpype.java.lang.System.out.println("hello world")
It works great inside the context of a "main" python program. However, inside the context of a running thread, I get the following response:
#
# 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
citing from the JPype documentation:
Python Threads
For the most part, python threads based on OS level threads (i.e posix threads), will work without problem. The only thing to remember is to call
jpype.attachThreadToJVM()
in the thread body to make the JVM usable from that thread. For threads that you do not start yourself, you can callisThreadAttachedToJVM()
to check.
HTH
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With