Author rhettinger
Recipients porton, rhettinger, xtreak
Date 2018-07-21.22:20:01
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1532211601.25.0.56676864532.issue34180@psf.upfronthosting.co.za>
In-reply-to
Content
The class is not documented to support __len__() or __bool__(), so this is not a bug.  There is an empty() method provided for the purposes of testing whether a queue is empty or not.  Likewise, there is a qsize() method for determining the current size.

Note, these methods have a built in race condition -- the information may be out of date by the time it is used.  In general, an EAFP approach is preferred for reliable behavior (i.e. call get() in a try/except to see whether an Empty exception is raised).

FWIW, this module's API was designed by Guido a long time ago.  Presumably, he had his reasons for choosing empty(), full(), and qsize() over the __len__() method.  Once the API has been published and then become widely used, the time for debating his API decisions is over and we work with it as published.
History
Date User Action Args
2018-07-21 22:20:01rhettingersetrecipients: + rhettinger, porton, xtreak
2018-07-21 22:20:01rhettingersetmessageid: <1532211601.25.0.56676864532.issue34180@psf.upfronthosting.co.za>
2018-07-21 22:20:01rhettingerlinkissue34180 messages
2018-07-21 22:20:01rhettingercreate