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

Stephane Bidoul stephane.bidoul@softwareag.com
Tue, 1 Apr 2003 21:46:59 +0200


> > Here's an example of how to release the GIL in C:
> > 
> > 	Py_BEGIN_ALLOW_THREADS;
> > 	/* Call into some C lib */
> > 	Py_END_ALLOW_THREADS;
> 
>   Hum, of course I assume it's an expensive operation. As a result
> I can't generate it for all calls to libxml2 or libxslt, and which
> call need it or not need to be manually selected, it's not something
> which can be automated. As a result it's a request for enhancement
> of my Python bindings but since it requires going over the full 
> set of entry point manually, and an update of the bindings generator
> don't expect it to be done quickly.

Also, if I remember well, you must be sure to reacquire the interpreter
lock before calling back into python (in the error handler callback, 
for instance).

-sbi