[Pythonmac-SIG] Threading and FrameWork.Application
Jack Jansen
Jack.Jansen@oratrix.com
Wed, 10 Apr 2002 11:41:30 +0200
On woensdag, april 10, 2002, at 09:39 , Just van Rossum wrote:
>> Shouldn't the toolbox call release the global interpreter lock?
>> Are there any toolbox calls for which this would be unsafe (i.e.
>> the calls that have a callback into Python, maybe)?
>
> WaitNextEvent() on the one hand should indeed release the GIL
> (as it blocks),
> but on the other hand it may call into Python at any time, due
> to a Carbon Event
> that wants to be handled. This would mean (I think) that at
> each Python callback
> entry point the GIL should be acquired again. And that in turn
> seems to mean
> that we should release the GIL when entering *any* call that
> could trigger a
> Carbon Event handler. Eg. RunApplicationEventLoop(),
> TrackMouseLocation(), etc.
That's more or less what I had in mind. All toolbox calls
release the GIL, and all callback routines re-acquire it.
But there's a gotcha here: any *other* calls to WaitNextEvent
also have to release the GIL. And some of those calls may not be
under our control (because they're in wxPython, or Tk, or
whereever)...
Hmm, and no documentation is available on the GIL and callback
routines (at least, I couldn't find anything, I looked in
"extending and embedding" and in the "Python/C API" docs). Maybe
this whole exercise is too dangerous, really...
--
- 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 -