You are viewing a plain text version of this content. The canonical link for it is here.
Posted to pylucene-dev@lucene.apache.org by "Andi Vajda (JIRA)" <ji...@apache.org> on 2013/11/04 16:02:17 UTC

[jira] [Commented] (PYLUCENE-28) JCC reuses JVM instances in impl, if compile() is called twice.

    [ https://issues.apache.org/jira/browse/PYLUCENE-28?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13812882#comment-13812882 ] 

Andi Vajda commented on PYLUCENE-28:
------------------------------------

A couple of comments. Your patch introduces a silent failure: if the second invocation of initVM() is made with different parameters (in particular, with a different classpath) people are going to be tearing their hair out with odd class loading errors because the 'second' classpath didn't take. Your patch should at least make sure that the classpath in the second invocation either matches the first or that the second classpath is forced into the existing VM (possible but hacky).

I didn't intend jcc to be used this way because of the one Java VM per process limitation and I thus consider your bug a feature request. It's a worthwhile feature nonetheless but it needs to be implemented more solidly. 

Maybe a better way to support this would be to introduce a new entrypoint in cpp.py that takes a VMEnv. That way, there is no silent failure possible, the user "knows" what VMEnv they have and passed in. Or maybe the jcc() function could take an optional VMEnv parameter - and check that no VM configuration params are passed in via args (and error if there are) in that case ?


> JCC reuses JVM instances in impl, if compile() is called twice.
> ---------------------------------------------------------------
>
>                 Key: PYLUCENE-28
>                 URL: https://issues.apache.org/jira/browse/PYLUCENE-28
>             Project: PyLucene
>          Issue Type: Improvement
>         Environment: jcc-svn-head (2.18-pre)
>            Reporter: Martin Scherer
>            Priority: Blocker
>              Labels: patch
>         Attachments: jvm_instance_check.patch
>
>
> If you import jcc.cpp to call compile yourself (a wrapped setup.py script to generate a wrapper on the fly, which seems to be a common use case), the current version complains about the JVM already being initialized before.
> The patch first checks for a running instance and creates one, if none is being found.
> For myself, this is a blocker, since it raises otherwise.
> Best, 
> Martin



--
This message was sent by Atlassian JIRA
(v6.1#6144)

Re: [jira] [Commented] (PYLUCENE-28) JCC reuses JVM instances in impl, if compile() is called twice.

Posted by Martin Scherer <m....@fu-berlin.de>.
Hi,

I've implemented your second suggestion and made the env an optional
parameter to the jcc function. In addition there are performed some
checks for classpath and vmargs for sanity.

This fixes the silent failure, when a different classpath should be
used. I didn't figure out, how to add dynamically to the existing
runtime, which is like you said very hackish.

Best,
Martin

Am 04.11.2013 16:02, schrieb Andi Vajda (JIRA):
> 
>     [ https://issues.apache.org/jira/browse/PYLUCENE-28?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13812882#comment-13812882 ] 
> 
> Andi Vajda commented on PYLUCENE-28:
> ------------------------------------
> 
> A couple of comments. Your patch introduces a silent failure: if the second invocation of initVM() is made with different parameters (in particular, with a different classpath) people are going to be tearing their hair out with odd class loading errors because the 'second' classpath didn't take. Your patch should at least make sure that the classpath in the second invocation either matches the first or that the second classpath is forced into the existing VM (possible but hacky).
> 
> I didn't intend jcc to be used this way because of the one Java VM per process limitation and I thus consider your bug a feature request. It's a worthwhile feature nonetheless but it needs to be implemented more solidly. 
> 
> Maybe a better way to support this would be to introduce a new entrypoint in cpp.py that takes a VMEnv. That way, there is no silent failure possible, the user "knows" what VMEnv they have and passed in. Or maybe the jcc() function could take an optional VMEnv parameter - and check that no VM configuration params are passed in via args (and error if there are) in that case ?
> 
> 
>> JCC reuses JVM instances in impl, if compile() is called twice.
>> ---------------------------------------------------------------
>>
>>                 Key: PYLUCENE-28
>>                 URL: https://issues.apache.org/jira/browse/PYLUCENE-28
>>             Project: PyLucene
>>          Issue Type: Improvement
>>         Environment: jcc-svn-head (2.18-pre)
>>            Reporter: Martin Scherer
>>            Priority: Blocker
>>              Labels: patch
>>         Attachments: jvm_instance_check.patch
>>
>>
>> If you import jcc.cpp to call compile yourself (a wrapped setup.py script to generate a wrapper on the fly, which seems to be a common use case), the current version complains about the JVM already being initialized before.
>> The patch first checks for a running instance and creates one, if none is being found.
>> For myself, this is a blocker, since it raises otherwise.
>> Best, 
>> Martin
> 
> 
> 
> --
> This message was sent by Atlassian JIRA
> (v6.1#6144)
> 


Re: [jira] [Commented] (PYLUCENE-28) JCC reuses JVM instances in impl, if compile() is called twice.

Posted by Andi Vajda <va...@apache.org>.
On Wed, 18 Dec 2013, Martin Scherer wrote:

> Hi Andi,
>
> do you suppose that adding to the classpath by runtime is possible via
> python or a java workaround?

You can see the horrible kludge implemented in JCCEnv::setClassPath().
It is possible to modify the classpath at runtime.

> I think it is very error prone if the user has to maintain his own
> classpath and can not rely on jcc.

Yes, classpaths are very error prone.

Andi..

>
> Best,
> Martin
>
>
> Am 04.11.2013 16:02, schrieb Andi Vajda (JIRA):
>>
>>     [ https://issues.apache.org/jira/browse/PYLUCENE-28?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13812882#comment-13812882 ]
>>
>> Andi Vajda commented on PYLUCENE-28:
>> ------------------------------------
>>
>> A couple of comments. Your patch introduces a silent failure: if the second invocation of initVM() is made with different parameters (in particular, with a different classpath) people are going to be tearing their hair out with odd class loading errors because the 'second' classpath didn't take. Your patch should at least make sure that the classpath in the second invocation either matches the first or that the second classpath is forced into the existing VM (possible but hacky).
>>
>> I didn't intend jcc to be used this way because of the one Java VM per process limitation and I thus consider your bug a feature request. It's a worthwhile feature nonetheless but it needs to be implemented more solidly.
>>
>> Maybe a better way to support this would be to introduce a new entrypoint in cpp.py that takes a VMEnv. That way, there is no silent failure possible, the user "knows" what VMEnv they have and passed in. Or maybe the jcc() function could take an optional VMEnv parameter - and check that no VM configuration params are passed in via args (and error if there are) in that case ?
>>
>>
>>> JCC reuses JVM instances in impl, if compile() is called twice.
>>> ---------------------------------------------------------------
>>>
>>>                 Key: PYLUCENE-28
>>>                 URL: https://issues.apache.org/jira/browse/PYLUCENE-28
>>>             Project: PyLucene
>>>          Issue Type: Improvement
>>>         Environment: jcc-svn-head (2.18-pre)
>>>            Reporter: Martin Scherer
>>>            Priority: Blocker
>>>              Labels: patch
>>>         Attachments: jvm_instance_check.patch
>>>
>>>
>>> If you import jcc.cpp to call compile yourself (a wrapped setup.py script to generate a wrapper on the fly, which seems to be a common use case), the current version complains about the JVM already being initialized before.
>>> The patch first checks for a running instance and creates one, if none is being found.
>>> For myself, this is a blocker, since it raises otherwise.
>>> Best,
>>> Martin
>>
>>
>>
>> --
>> This message was sent by Atlassian JIRA
>> (v6.1#6144)
>>
>

Re: [jira] [Commented] (PYLUCENE-28) JCC reuses JVM instances in impl, if compile() is called twice.

Posted by Martin Scherer <m....@fu-berlin.de>.
Hi Andi,

do you suppose that adding to the classpath by runtime is possible via
python or a java workaround?

I think it is very error prone if the user has to maintain his own
classpath and can not rely on jcc.

Best,
Martin


Am 04.11.2013 16:02, schrieb Andi Vajda (JIRA):
> 
>     [ https://issues.apache.org/jira/browse/PYLUCENE-28?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13812882#comment-13812882 ] 
> 
> Andi Vajda commented on PYLUCENE-28:
> ------------------------------------
> 
> A couple of comments. Your patch introduces a silent failure: if the second invocation of initVM() is made with different parameters (in particular, with a different classpath) people are going to be tearing their hair out with odd class loading errors because the 'second' classpath didn't take. Your patch should at least make sure that the classpath in the second invocation either matches the first or that the second classpath is forced into the existing VM (possible but hacky).
> 
> I didn't intend jcc to be used this way because of the one Java VM per process limitation and I thus consider your bug a feature request. It's a worthwhile feature nonetheless but it needs to be implemented more solidly. 
> 
> Maybe a better way to support this would be to introduce a new entrypoint in cpp.py that takes a VMEnv. That way, there is no silent failure possible, the user "knows" what VMEnv they have and passed in. Or maybe the jcc() function could take an optional VMEnv parameter - and check that no VM configuration params are passed in via args (and error if there are) in that case ?
> 
> 
>> JCC reuses JVM instances in impl, if compile() is called twice.
>> ---------------------------------------------------------------
>>
>>                 Key: PYLUCENE-28
>>                 URL: https://issues.apache.org/jira/browse/PYLUCENE-28
>>             Project: PyLucene
>>          Issue Type: Improvement
>>         Environment: jcc-svn-head (2.18-pre)
>>            Reporter: Martin Scherer
>>            Priority: Blocker
>>              Labels: patch
>>         Attachments: jvm_instance_check.patch
>>
>>
>> If you import jcc.cpp to call compile yourself (a wrapped setup.py script to generate a wrapper on the fly, which seems to be a common use case), the current version complains about the JVM already being initialized before.
>> The patch first checks for a running instance and creates one, if none is being found.
>> For myself, this is a blocker, since it raises otherwise.
>> Best, 
>> Martin
> 
> 
> 
> --
> This message was sent by Atlassian JIRA
> (v6.1#6144)
>