[Python-Dev] Threading and callbacks - missing documentation

Jack Jansen Jack.Jansen@oratrix.com
Fri, 12 Apr 2002 23:59:20 +0200

currently work, should we really try to fix them with TLS?

What I would like to see, though, is a way to get at the thread 
state iff the current platform has thread local storage.

My direct problem (the MacPython/MachoPython one, the work 
problem is different) is that various MacOS API calls such as 
WaitNextEvent() can cause callbacks to be called (in the current 
thread). And as these calls block I'd like to bracket them with 
PY_BAT/PY_EAT. But I know that in both MacPython and MachoPython 
I have pthreads, and thus TLS, and thus I can count on using it 
in the callback routine.

Moreover, using the TLS only for callback routines allows me to 
go one further. If other packages that I use (Tk, for instance) 
call WaitNextEvent while holding the interpreter lock it could 
cause on of "my" callbacks to be called. But if we have both the 
TLS and the old mechanism we can detect the situation that the 
callback is called from the thread holding the interpreter lock 
and we can compensate for it.
- Jack Jansen        <Jack.Jansen@oratrix.com>        
http://www.cwi.nl/~jack -
- If I can't dance I don't want to be part of your revolution -- 
Emma Goldman -