global interpreter lock not working as it should

brueckd at tbye.com brueckd at tbye.com
Wed Jul 31 00:27:43 EDT 2002


On Tue, 30 Jul 2002, anton wilson wrote:

> > Just curious: how do you explain all the multithreaded Python programs
> > that currently work just fine? Are these all flukes?
> 
> This brings me to the second reason that your program seems to work.
> The Linux OS gives threads time-slices and when these time-slices are used up 
> every 150 or so milliseconds, the process is forcibly removed from the CPU.
> I presume that the reason your program seems to work is that in the time 
> between when a thread releases the GIL and a thread tries to reaquire the 
> GIL, it is forcibly removed from the CPU, and the other thread can now run. 
> This would not be a rare occurence due to the high frequency at which the 
> lock is released.

Well, I guess you can believe what you want. :-) But at my last job I had
multithreaded Python programs running just fine on Windows, Linux, and
Solaris and they worked great. In fact, some of them were direct ports of
C/C++ code - there was no need to change the approach to using threads
because it worked pretty much the same in C as in Python. At my current
job I have production multithreaded Python programs in both Windows and
Linux, and again, I'm not doing anything 'special' to 'deal' with the GIL
or anything like that. I guess it seems a bit hard for me to believe that
they just 'seem' to work; I know for myself, from direct experience, that
they really do work great.

-Dave





More information about the Python-list mailing list