def producer(e, q): for i in range(10): q.put(i) time.sleep(0.1) logging.debug('produce {0}'.format(i)) if q.empty(): e.set()