[Python-3000] Useless methods in Queue module
skip at pobox.com
skip at pobox.com
Mon Jan 14 22:54:42 CET 2008
Leif> I think the point is that, with multiple threads, those methods
Leif> are not guaranteed to be correct, whereas trapping the exceptions
Leif> apparently are, and therefore, leaving those methods in is
Leif> confusing to new programmers who might assume they work and use
Leif> them without a second thought.
For the guy who said he wanted to maintain an average qsize (not too small,
not too big), empty() and full() don't help. He'll have to implement a
qsize() function or monkey patch (or subclass) the Queue class. I agree
with Guido that empty() and full() can go with no great consequence.
qsize() should stay though. In my old threading code (stuff I no longer
use) qsize() was the only one of the three I ever used.
That said, I don't understand why things can't just be left as-is. I can't
see that they are hurting anything. All three have long been documented as
not reliable. It's not like it should be a surprise to anyone that
if not q.qsize():
print q.qsize()
might print something besides 0. And if it is a surprise, they should
probably not be programming with threads. <0.5-even-rounded wink>
Skip
More information about the Python-3000
mailing list