class ItemStore(object):

    def __init__(self):
        self.cond = threading.Condition()
self.items = []

def add(self, item):
    with self.cond:
        self.items.append(item)
self.cond.notify()

def getAll(self, blocking=False):
    with self.cond:
        while blocking and len(self.items) == 0:
            self.cond.wait()
items, self.items = self.items, []
return items
Get all items from thread Queue