[Python-Dev] Extension modules, Threading, and the GIL
Aahz
aahz@pythoncraft.com
Mon, 30 Dec 2002 09:59:12 -0500
On Sun, Dec 29, 2002, David Abrahams wrote:
>
> Python extension module B calls shared library Q and uses Q's callback
> interface. Because some of the callbacks need to use the Python API,
> and *might* be invoked by threads, they must all acquire the GIL.
> Because they also might be invoked by direct calls into Q, B must
> always release the GIL before calling anything in Q.
So you're saying that the callback functions in B acquire the GIL?
> Problem: using B while A is loaded breaks A: because B has installed
> callbacks in Q that acquire the GIL, A must also release the GIL
> before calling into Q.
Why? The callbacks in B will simply hang until they acquire the GIL.
I think this thread might be better handled on c.l.py, at least until
it's understood well enough to be clear whether something does need to
change in Python.
--
Aahz (aahz@pythoncraft.com) <*> http://www.pythoncraft.com/
"There are three kinds of lies: Lies, Damn Lies, and Statistics." --Disraeli