Threads in embedded interpreter doesn't run

Jeff Shannon jeff at ccvcorp.com
Thu Oct 21 15:27:15 EDT 2004


devrim.erdem at gmail.com wrote:

>Jeff Shannon <jeff at ccvcorp.com> wrote in message news:<10nbdfqhgkgra70 at corp.supernews.com>...
>  
>
>>devrim.erdem at gmail.com wrote:
>>
>>    
>>
>>>Could anyone give me some hints to understand why the thread can not
>>>execute during my application loop.
>>>
>>>      
>>>
>>This is a complete shot in the dark, but is there any chance that your 
>>rendering loop is holding on to the Python GIL?  Doing so would prevent 
>>any (other) Python code from running for as long as the lock is held.
>>    
>>
>
>Thanks Jeff.
>
>I haven't so far explicitly done anything with Python GIL in my
>application. Is there a function which could tell me if the Python GIL
>is held or not ?
>  
>

I've never done any extending/embedding, so I don't really know; I'm 
just working with what I've seen mentioned here on c.l.py (and I usually 
skip extending/embedding threads, since I don't do it).  But I believe 
that the GIL is released and reclaimed by (from vague memory) 
PyBeginAllowThreads and PyEndAllowThreads, or something like that.  
You'll need to read through the extending/embedding docs to figure out 
how they work, though, because I don't know enough to help you there.  
:)  Just remember that you can't touch any Python internals (or do much 
of anything through the interpreter) unless you hold the GIL, and that 
no other Python threads can run while you hold it.

Jeff Shannon
Technician/Programmer
Credit International




More information about the Python-list mailing list