Queue qsize = unreliable?

Michael Hudson mwh at python.net
Fri Aug 6 11:33:20 EDT 2004


"James R. Saker Jr." <jsaker at americanrelay.com> writes:

> I see per pydoc that Queue.Queue()'s .qsize is allegedly unreliable:
> 
>      |  qsize(self)
>      |      Return the approximate size of the queue (not reliable!).
> 
> Any thoughts on why this is unreliable (and more curiously, why it would
> be put in there as an unreliable function?) Rather than roll my own
> threaded fifo class, it would seem prudent to use Python's built-in
> Queue but the warning signs on a rather necessary function seem curious.

Well, by the time you examine (or even get!) the answer, it might be
wrong.  Kinda hard to avoid this in the setting of multiple threads!

Cheers,
mwh

-- 
 All parts should go together without forcing. You must remember that
 the parts you are  reassembling were disassembled by you.  Therefore,
 if you can't get them together again, there must be a reason. By all
 means, do not use a hammer.           -- IBM maintenance manual, 1925



More information about the Python-list mailing list