[XML-SIG] Advice on how to deal with locking problems using python-wrapped C libs in MT frameworks like Zope/Twisted?

Craeg K Strong cstrong@arielpartners.com
Sun, 30 Mar 2003 16:33:10 -0500

See below:

Martin v. L=F6wis wrote:

>Craeg K Strong <cstrong@arielpartners.com> writes:
> =20
>>When libxslt tries to resolve the relative URL, a request is going out
>>to grab:
>>which ends up coming back in to Zope.  Zope is multi-threaded, so why
>>shouldn't that be able to return successfully?  Is libxslt-python someh=
>>holding on to the GIL or-- maybe it is still in the middle of the "read=
>>call and is therefore holding a lock on that resource?
>>   =20
>One would have to know a lot of internal details here that you
>probably have to investigate yourself, unless you can find some
>Zope-and-libxslt guru. Here are some theories:
>1. Zope is not responding since it considers the request incomplete
>   One would have to study the 88 bytes request data (use -s2000 on
>   strace) to determine whether the request is complete - yet Zope
>   may *still* waiting for more data for some reason (e.g. a bug).
>2. Zope is not configured to process more than one request. It accepts
>   the connection only since this is in the listen backlog; it doesn't
>   actually read the data - not because it couldn't, but because it
>   does not want to.
>3. The GIL is held while libxslt makes this request.
>If I think long enough, I can come up with more consistent theories :-)
>Which of these are plausible, I don't know; most likely, the real
>reason would not give a plausible theory.
>What mechanism in libxslt does make the callback? Is that Python code,
>or code implemented in libxslt itself?
I am not sure.  The callback is probably in C code.   However, the GIL=20
may have
been locked before that by the Python wrapper.   libxslt-python may=20
employ that
strategy-- lock GIL, descend into C code, return, unlock GIL.    I don't=20
really know...
Are there some specified questions to ask Daniel?



> =20

Craeg K Strong, General Partner
Ariel Partners LLC
voice 781-647-2425
fax   781-647-9690

NOTICE: This message is for the sole use of the intended recipient(s)
and may contain confidential and privileged information. Any review,
retransmission, dissemination or other use of, or taking of any action
in reliance upon, this information by persons or entities other than
the intended recipient is prohibited. If you are not the intended
recipient, please contact the sender by reply email and destroy all
copies -- including electronic copies -- of the original message.