I agree that the “rough” is not the clearest choice of words, but, as Ned argues, they are trying to indicate that just because the queue size at time t1 was 7 does not mean that it will still be size 7, when you click or post values later.
The problem is that as long as the size returned with qsize is still correct, when you go to pushing / popping a value from this queue, it may unexpectedly behave in a multi-threaded environment.
For example:
q = Queue() if q.qsize > 0:
This is an LBYL “Look in front of you” example, and it is dangerous due to the potential state of the race here when multiple threads are accessing the queue.
In this case, you must approve the EAFP or "apologize except for permission" and do the following:
from Queue import Queue, Empty import time q = Queue() try: item = q.get(False)
stderr
source share