class SynchronousQueue(object):

    def __init__(self):
        self.q = Queue(1)
self.put_lock = RLock()

def get(self):
    value = self.q.get(block=True)
self.q.task_done()
return value

def put(self, item):
    with self.put_lock:
        self.q.put(item, block=True)
self.q.join()
Good way to build a blocking, zero-length queue in Python