On Wed, 12 Jan 2011, Roman Chyla wrote:
And if in the python, I will do:
import lucene
import lucene.initVM(lucene.CLASSPATH)
Will it work in this case? Giving access to the java classes from
inside python. Or I will have to forget pylucene, and prepare some
extra java classes? (the jcc in reverse trick, as you put it)
Yes, just be sure to JCC-build your eggs with --import lucene so that you
don't wrap lucene multiple times.
- you say that threads are not managed by the Python VM, does that
mean there is no Python GIL?
No, there is a Pythonn GIL (and that is the Achille's Heel of this setup if
you expect high concurrent servlet performance from your server calling
Python). That Python GIL is connected to this thread state I was mentioning
earlier. Because the thread is not managed by Python, when Python is called
(by way of the code generated by JCC) it doesn't find a thread state for the
thread and creates one. When the call completes, the thread state is
destroyed because its refcount goes to zero. My TerminatingThread class
acquires a Python thread state and keeps it for the life of the thread,
thereby working this problem around.
OK, this then looks like a normal Python - which is somehow making me
less worried :) I wanted to use multiprocessing inside python to deal
with GIL, and I see no reason why it should not work in this case.
I tried that approach originally and gave up. There were too many strange
lock-ups talking to python subprocesses managed by multiprocessing. Now,
this was before it became part of Python's distribution so maybe bugs got
fixed since then.
Andi..