Queue question

Steve M sjmaster at gmail.com
Sat Oct 15 19:31:32 EDT 2005


According to my "Python in a Nutshell":

q.get(block=True)

is the signature, so, as you use it above, the call will hang until
something is on the queue. If block is false and the queue is empty,
q.get() will raise the exception Empty.

q.get_nowait is apparently synonymous with q.get(block=False)


q.not_empty, if it existed, I expect would be true just in case there
was at least one item in the queue. But according to my book there is
q.empty and q.full, which is true when the queue has the maximum
allowed number of items (a value specified when the queue is created).

Also, I don't think you can rely on q.empty in the way you may expect.
For example, another thread can empty the queue between the time you
test whether q.empty is false and the time you call q.get.




More information about the Python-list mailing list