lucene-pylucene-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Andi Vajda <va...@apache.org>
Subject Re: calling Python from Java fails...
Date Sat, 02 Jul 2011 20:36:02 GMT

On Fri, 1 Jul 2011, Bill Janssen wrote:

> Andi Vajda <vajda@apache.org> wrote:
>
>> That being said, if you send in javadoc patches, I agree, the results
>> should be published like they are on the lucene/java site (under
>> resources) and I can take care of that.
>
> Here's a patch (against the JCC branch_3x):

Thank you, Bill, for the patch.
It's integrated into revs 1142290 and 1142294.
I added a javadoc invocation to jcc's setup.py and a link to the javadocs 
under JCC -> Documentation and refreshed the published site.
Give it a few hours to be visible.

Andi..

>
> --- java/org/apache/jcc/PythonVM.java	(revision 1141989)
> +++ java/org/apache/jcc/PythonVM.java	(working copy)
> @@ -23,6 +23,18 @@
>         System.loadLibrary("jcc");
>     }
>
> +    /**
> +     * Start the embedded Python interpreter.  The specified
> +     * programname and args are set into the Python variable sys.argv.
> +     * This returns an instance of the Python VM; it may be called
> +     * multiple times, and will return the same VM instance each time.
> +     *
> +     * @param programName the name of the Python program, typically
> +     * /usr/bin/python.  This is informational; the program is not
> +     * actually executed.
> +     * @param args additional arguments to be put into sys.argv.
> +     * @return a singleton instance of PythonVM
> +     */
>     static public PythonVM start(String programName, String[] args)
>     {
>         if (vm == null)
> @@ -34,11 +46,28 @@
>         return vm;
>     }
>
> +    /**
> +     * Start the embedded Python interpreter.  The specified
> +     * programname is set into the Python variable sys.argv[0].
> +     * This returns an instance of the Python VM; it may be called
> +     * multiple times, and will return the same VM instance each time.
> +     *
> +     * @param programName the name of the Python program, typically
> +     * /usr/bin/python.  This is informational; the program is not
> +     * actually executed.
> +     * @return a singleton instance of PythonVM
> +     */
>     static public PythonVM start(String programName)
>     {
>         return start(programName, null);
>     }
>
> +    /**
> +     * Obtain the PythonVM instance, or null if the Python VM
> +     * has not yet been started.
> +     *
> +     * @return a singleton instance of PythonVM, or null
> +     */
>     static public PythonVM get()
>     {
>         return vm;
> @@ -50,9 +79,33 @@
>
>     protected native void init(String programName, String[] args);
>
> +    /**
> +     * Instantiate the specified Python class, and return the instance.
> +     *
> +     * @param moduleName the Python module the class is defined in
> +     * @param className the Python class to instantiate.
> +     * @return a handle on the Python instance.
> +     */
>     public native Object instantiate(String moduleName, String className)
>         throws PythonException;
>
> +    /**
> +     * Bump the Python thread state counter.  Every thread should
> +     * do this before calling into Python, to prevent the Python
> +     * thread state from being inadvertently collected.
> +     *
> +     * @return the Python thread state counter.  A return value less
> +     * than zero signals an error.
> +     */
>     public native int acquireThreadState();
> +
> +    /**
> +     * Release the Python thread state counter.  Every thread that has
> +     * called acquireThreadState() should call this before
> +     * terminating.
> +     *
> +     * @return the Python thread state counter.  A return value less
> +     * than zero signals an error.
> +     */
>     public native int releaseThreadState();
> }
>

Mime
View raw message