[lxml-dev] Error with thread
Stefan Behnel
stefan_ml at behnel.de
Mon Oct 29 17:36:51 CET 2007
Hi,
Frédéric Mantegazza wrote:
> I have a problem with a XSLT filter:
>
> Traceback (most recent call last):
> File "/home/pymad/PyMAD/server/macros/freeScan.py", line 247, in doAction
> DataManager().newScanPoint(numPoint, 'NSF')
> File "/home/pymad/PyMAD/server/managers/dataManager.py", line 253, in
> newScanPoint
> self.__scan.setPoint(numPoint, numPal)
> File "/home/pymad/PyMAD/server/data/scanData.py", line 221, in setPoint
> self.__serialize()
> File "/home/pymad/PyMAD/server/data/scanData.py", line 196, in __serialize
> filter_.dumpScan(self.__tree, self.__scanBaseName)
> File "/home/pymad/PyMAD/server/data/dataFilters.py", line 122, in dumpScan
> result = self.__xslFilter.apply(tree, fileName="'%s'" % baseName)
> File "xslt.pxi", line 450, in etree.XSLT.apply
> File "xslt.pxi", line 356, in etree.XSLT.__call__
> RuntimeError: stylesheet is not usable in this thread
>
> This error ocurs on a machine, and not on another, which has the same
> install (debian etch, lxml 1.1.1).
That's a pretty old version, but the general restriction still applies. You
cannot use an XSLT object in a different thread if it was not created in the
main thread (that's due to some optimisations in libxslt).
Try preparing the stylesheets in the main thread. Or, if you do not control
the main thread, consider creating them on the fly and maybe caching them in
thread local storage.
Stefan
More information about the lxml-dev
mailing list