using lxml with mod_wsgi in apache

Bug #1713707 reported by Hinnack
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
lxml
Won't Fix
Undecided
Unassigned

Bug Description

I am using LXML in a web app running under apache.
I am using it for a xsl transformation which has custom functions in it:

    ns = etree.FunctionNamespace('http://mediafactory.de/func')
    ns['convertBin'] = convertBin

when I want to use IO for writing or the PIL module in the convertBin() function I get an error.

This one only goes away, if I switch WSGIApplicationGroup to %{GLOBAL}
The wsgi documentation says:
Any WSGI applications in the global application group will always be executed within the context of the first interpreter created by Python when it is initialised. Forcing a WSGI application to run within the first interpreter can be necessary when a third party C extension module for Python has used the simplified threading API for manipulation of the Python GIL and thus will not run correctly within any additional sub interpreters created by Python.
http://modwsgi.readthedocs.io/en/develop/configuration-directives/WSGIApplicationGroup.html

Revision history for this message
scoder (scoder) wrote :

Thanks for the report.

You didn't say what kind of error you got, but since you already quoted the relevant section of the docs, it's probably a crash.
Subinterpreters are barely supported by any extension modules in CPython, and not at all (currently) by Cython. Probably doable in general, but then, libxml2/libxslt also have some corners where they require global state (as opposed to per-thread or per-subinterpreter state).

In short: difficult, and won't happen any time soon.

Changed in lxml:
status: New → Won't Fix
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.