[Pythonmac-SIG] Threading and FrameWork.Application

Jack Jansen Jack.Jansen@oratrix.com
Mon, 8 Apr 2002 17:48:30 +0200


On maandag, april 8, 2002, at 02:53 , Just van Rossum wrote:

> Jack Jansen wrote:
>
>> Well, the call I'm looking for would definitely have to give up
>> the global interpreter lock before doing the call to give up the
>> CPU. And it turns out GUSI's sleep(0) (or usleep(0), for that
>> matter) does exactly what we want: it allows a threadswitch
>> without further delay.
>
> Why would you even have to think about the GIL when you're in 
> an all-Python
> event loop? Or is it that no switching occurs once we're in 
> WaitNextEvent?

Indeed, no *thread* switching occurs in WNE(), only 
*application* switching. Or, in other words, if you're doing a 
WNE() loop without any other (file, socket) I/O you won't get 
any thread switch. This could be seen as a problem in GUSI (it 
pretends to implement preemptive threads, but they're only 
preempive really if you do enough GUSI I/O calls), but there's 
little to be done about this given the MacOS (<=9) architecture.

--
- 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 -