[pylucene-dev] Automatic call to finalize

Andi Vajda vajda at osafoundation.org
Thu Jan 17 11:26:36 PST 2008


On Thu, 17 Jan 2008, Andi Vajda wrote:

> On Thu, 17 Jan 2008, anurag uniyal wrote:
>
>> I have a custom parser which is created and used to parse queries at 
>> several places. Instead of calling finalize each time, I have wrapped my 
>> custom parser in a python class and keep a ref to it, delegating all calls 
>> and it works well, without any weakrefs.
>
>> Do you think such behaviour is correct and please tell if it can create any 
>> problems?
>
> This looks like it could work. There are caveats with using python __del__() 
> methods and objects involved in cycles. See 'garbage' list docs [1].

It looks like I spoke too fast. When returning an object to Java such as a 
custom token stream in an analyzer's tokenStream() method, if the finalizer 
wrapper is returned, a type error might be raised. If the wrappee is 
returned, then it might get finalized too soon if the wrapper is freed by 
python when java is still using the wrappee.

Andi..


More information about the pylucene-dev mailing list