global interpreter lock not working as it should

Tim Peters tim.one at comcast.net
Tue Jul 30 18:32:43 EDT 2002


[anton wilson]
> I think I understand what you mean. I assumed that python should
> block and allow others to work every x byte codes on EVERY platform. I
> see that that's a wrong assumption.

It wasn't our intent, no -- we expect the platform thread library to do
switching when it thinks it's best to do so.  On Windows, for example,
threads are very happy to switch frequently, but then Windows is a
thread-happy OS geared toward interactive GUIs.  Linux is more reluctant.
For a while, it used to take a stick of dynamite to convince Solaris to
switch threads.  Etc; the pragmatics of various thread implementations
aren't something Python wants to second-guess.

I'll note one other odd thing:  sys.setcheckinterval() exists in Python so
you can change how often Python *offers* to switch threads.  Production
systems on Linux that care almost always boost it, not lower it; for
example, Zope boosts it to 120, because Linux was switching threads "too
often" under the default setting for its uses of threads.  Thread switches
incur real costs too.





More information about the Python-list mailing list