[Python-Dev] Pythonic concurrency

Greg Ewing greg.ewing at canterbury.ac.nz
Tue Oct 11 02:09:03 CEST 2005


Ian Bicking wrote:

> What the GIL-ranters don't get is that the GIL actually gives you just 
>  enough determinism to be able to write threaded programs that don't crash,

The GIL no doubt helps, but your threads can still get
preempted between bytecodes, so I can't see it making
much difference at the Python thought-level.

I'm wondering whether Python threads should be
non-preemptive by default. Preemptive threading is
massive overkill for many applications. You don't
need it, for example, if you just want to use threads
to structure your program, overlap processing with I/O,
etc.

Preemptive threading would still be there as an option
to turn on when you really need it.

Or perhaps there could be a priority system, with a
thread only able to be preempted by a thread of higher
priority. If you ignore priorities, all your threads
default to the same priority, so there's no preemption.
If you want a thread that can preempt others, you give
it a higher priority.

-- 
Greg Ewing, Computer Science Dept, +--------------------------------------+
University of Canterbury,	   | A citizen of NewZealandCorp, a	  |
Christchurch, New Zealand	   | wholly-owned subsidiary of USA Inc.  |
greg.ewing at canterbury.ac.nz	   +--------------------------------------+


More information about the Python-Dev mailing list