The Python Way

Tim Peters tim.one at comcast.net
Tue Apr 2 16:29:41 EST 2002


[Andy Gimblett]
> So, is Aahz/Tim saying that Queue.Queue is "better" in general than
> threading.RLock ?  If so, why?

It's almost impossible to get yourself in trouble using Queue.  It's almost
(but not quite as) impossible *not* to get yourself in trouble rolling your
own protocols by hand via raw locks.  If you can't use a Queue, learn how to
use conditional variables correctly -- they support a protocol that's very
robust, but needs to be learned.  Locks are fine for pure, unconditional
mutual exclusion, but even then, sooner or later you're going to forget to
code the try/finally wrapper and end up baffled by deadlock.

it's-not-a-question-of-"better"-unless-you-assume-sanity-is-better-ly
    y'rs  - tim





More information about the Python-list mailing list