Message322125
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. |
|
Date |
User |
Action |
Args |
2018-07-21 22:20:01 | rhettinger | set | recipients:
+ rhettinger, porton, xtreak |
2018-07-21 22:20:01 | rhettinger | set | messageid: <1532211601.25.0.56676864532.issue34180@psf.upfronthosting.co.za> |
2018-07-21 22:20:01 | rhettinger | link | issue34180 messages |
2018-07-21 22:20:01 | rhettinger | create | |
|