On 11-Jan-08, at 11:13 AM, Raymond Hettinger wrote: > I proposed to remove three methods from the queue module, qsize(), > empty(), and full(). These are not reliable. The RightWay (tm) is > to trap the Empty and Full exceptions or use the .join() approach.
-1. There are several "advisory" use cases for these methods where the reliability of the answer when .get/.put is not important. For instance, as Aahz mentioned, being able to log the size of the queue is extremely useful (also, for unittesting). Another, more substantive use case is as follows: I have an asyncore.dispatcher implementation that reads output from a Queue.Queue to put on the wire. It is necessary here to implement .writable(), which should return True if there is a possibility that there is data to be written (so asyncore can poll for writability in the select() loop). "return not queue.empty()" does the trick. Of course, when it comes time to write to the socket, it is still necessary to catch Empty exceptions, and do nothing in that case. -Mike _______________________________________________ Python-3000 mailing list [email protected] http://mail.python.org/mailman/listinfo/python-3000 Unsubscribe: http://mail.python.org/mailman/options/python-3000/archive%40mail-archive.com
