4suite XSLT thread safe ?

Diez B. Roggisch deetsNOSPAM at web.de
Wed Jan 26 10:24:35 EST 2005

> If a thread that are using a XSLT processor looses the GIL within the
> transformation process and another one starts processing on the same
> processor will this work?
> Will the half-way finished thread be in the way of the one starting the
> processing before the stoped thread are done.
> I think that's what I ment. Can a XSLT processor object be shared
> between multiple threads?

No  - as a simple test reveals:

#The identity transform: duplicates the input to output
TRANSFORM = """<xsl:stylesheet
xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">

<xsl:template match="@*|node()">
    <xsl:apply-templates select="@*|node()"/>


#And I don't even like Monty Python, folks
SOURCE1 = """<spam id="eggs">What do you mean "bleah"</spam>"""
SOURCE2 = """<spam id="eggs">I don't like spam</spam>"""

import threading
from Ft.Xml.Xslt import Processor
processor = Processor.Processor()
import time, sys
from Ft.Xml import InputSource

transform = InputSource.DefaultFactory.fromString(TRANSFORM,


#Now the processor is prepped with a transform and ccan be used
#over and over for the same transform
results = []
source = InputSource.DefaultFactory.fromString(SOURCE1,
source2 = InputSource.DefaultFactory.fromString(SOURCE2,
# comment the following line to make things crash.

print results


Diez B. Roggisch

More information about the Python-list mailing list