extension call backs and the GIL

Aahz aahz at pythoncraft.com
Mon Sep 29 07:03:21 EDT 2003


In article <pUnrihASxAe$EwRO at jessikat.fsnet.co.uk>,
Robin Becker  <robin at jessikat.fsnet.co.uk> wrote:
>
>I'm trying to better my understanding of multithreading. I believe a
>thread that calls an extension must have the GIL. What happens if the
>extension then calls back into Python? Can a function or method somehow
>'belong' to a different thread? My understanding was that things should
>be OK provided the extension code doesn't mess with the GIL (which it
>doesn't).

You need to reacquire the GIL prior to making the callback.
-- 
Aahz (aahz at pythoncraft.com)           <*>         http://www.pythoncraft.com/

"It is easier to optimize correct code than to correct optimized code."
--Bill Harlan




More information about the Python-list mailing list