[Python-Dev] Re: post mortem after threading deadlock?

Guido van Rossum guido@zope.com
Wed, 25 Jul 2001 18:16:45 -0400

> I've got better advice <wink>:  Never use semaphores for anything.  Never
> use locks except for dirt-simple one- or two-line critical sections.  For
> everything but the latter, always use condition variables.  They're the only
> synch protocol I've seen that non-specialist thread programmers can use
> without routinely screwing themselves.  The genius of the condvar protocol
> is that, used correctly, you *always* run-time test your crucial assumptions
> about non-local state (and automatically do so under the protection of a
> critical section), and *always* loop back to try again if your hopes or
> assumptions turn out not to be true.  This saves you from a universe of
> possible problems with non-local state changing in unanticipated ways.

I believe that Aahz, in his thread tutorial, has even more radical
advice: use the Queue module for all inter-thread communication.  It
is even higher level than semaphores, and has the same nice

--Guido van Rossum (home page: http://www.python.org/~guido/)