[lxml-dev] Proxy AssertionError in threaded tree traversal

Stefan Behnel stefan_ml at behnel.de
Fri Feb 16 11:09:01 CET 2007


Hi again,

Stefan Behnel wrote:
> Holger Joukl wrote:
>> Is the compiled-to-C _registerProxy function an atomic operation regarding
>> GIL-
>> locking? Because inside it uses Python-API calls itself, wouldn't that mean
>> there can be a thread change when in the function?
> 
> I think this is possible if there is any real Python code executed by the
> interpreter, which can happen if you instantiate Python subclasses for
> Elements (you had Python type classes, right?).
> 
> You can try putting a lock around the code executed in _elementFactory().
> Acquire it before the call to getProxy() and release it after registerProxy().
> Don't forget to also release it before any 'return', though. Take a look into
> parser.pxi for an example.

Here's a patch for this, against the current trunk. Could you please check if
that solves this problem?

Thanks,
Stefan

-------------- next part --------------
A non-text attachment was scrubbed...
Name: element-factory-lock.patch
Type: text/x-patch
Size: 1505 bytes
Desc: not available
Url : http://codespeak.net/pipermail/lxml-dev/attachments/20070216/30111b53/attachment.bin 


More information about the lxml-dev mailing list