I have an inter-process queue that is usually empty and only once in a while does something appear in it. In one of my threads I want to define a while loop like this:
def mythread(queue1):
while (queue1.get_nowait() != 1):
#do stuff
This works great until the queue is empty which happens quickly in my case. When the queue is empty calling get_nowait() or get(False) raises the empty queue exception. Is there any way to check the queue without blocking AND without raising the empty exception?