The Python Way

Gordon McMillan gmcm at hypernet.com
Tue Apr 2 08:47:54 EST 2002


Andy Gimblett wrote:

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

It's not that Queue.Queue is "better" than RLock (Queue was written
before threading.py, but if it had been written after, I would
expect it to use a Condition which uses an RLock.)

What's "better" is keeping the number of "shared" (really, "contended")
resources to a minimum. If your threads only meet through Queues,
you have virtually no chance of ending up deadlocked.

It's really a design philosophy: each resource should be owned
by one and only one thread.

-- Gordon
http://www.mcmillan-inc.com/



More information about the Python-list mailing list