Multi-threading python

Aahz aahz at pythoncraft.com
Wed Sep 11 13:06:13 EDT 2002


In article <alnmcs$gdt$1 at news.netpower.no>,
David Brown <david at no.westcontrol.spam.com> wrote:
>
>If C code (or other extensions) that take significant time, or block for
>other reasons, release the GIL then there I suppose there is not going to be
>much of a problem.  The point is to maximize the throughput, and avoid
>threads blocking each other unnecessarily.

Yup.

>It sounds like that is only true for code that does a lot of work in pure
>python (rather than with time-consuming, GIL-released C code).

Yup.

>Thanks for the information - it was definitely helpful.  It looks like the
>system used by Python will work fine in all but a few situations (SMP system
>in which a lot of work is being done in Python itself, rather than in
>extension modules - or in badly written extensions which don't release the
>GIL before doing heavy work).  Such situations can be dealt with by running
>two python processes - if a program really needs to do hard SMP work in
>python, then that is a small price to pay since I image the GIL simplifies a
>lot of things.  I had been worried that the Python threading scheme would
>have caused more inefficiences (such as all threads stopping while a single
>thread was blocked for I/O).

Yup.
-- 
Aahz (aahz at pythoncraft.com)           <*>         http://www.pythoncraft.com/

Project Vote Smart: http://www.vote-smart.org/



More information about the Python-list mailing list