[Python-3000] Useless methods in Queue module
mike.klaas at gmail.com
Mon Jan 14 23:55:56 CET 2008
On 14-Jan-08, at 1:32 PM, Charles Merriam wrote:
> Not to be pedantic, but the major concern others are voicing is that
> is that queue size is not reliable and is therefore a potential source
> of hard to find threading bugs by naive users. Why not just rename
> q.size() to the unweildy name of q.est_size()?
This is a misleading name. The number returned from qsize() [not size
()] is perfectly reliable, in the sense that it is the exact size of
the queue at some instant in time. The real concern is that qsize()
> 0 doesn't guarantee that a subsequent .get() will not block, nor
that qsize() < maxsize guarantee that .put() will not block.
Incidentally, I find this warning much less confusion than the vague
"Because of multithreading semantics, this number is not reliable."
in the docs.
More information about the Python-3000