def main(zk): p = Producer(zk) p.put(1, priority=0) p.put(2, priority=50) p.put(3) # default to lowest priority c = Consumer(zk) try: elements = [] while True: data = c.reserve() if data is None: break elements.append(int(data)) assert elements == [1, 2, 3] print "Ok." finally: c.close()
def main(zk): p = Producer(zk) p.put(1, priority = 0) p.put(2, priority = 50) p.put(3) # default to lowest priority c = Consumer(zk) try: elements = [] while True: data = c.reserve() if data is None: break elements.append(int(data)) assert elements == [1,2,3] print "Ok." finally: c.close()
def child_main(): zk = create_zk() c = Consumer(zk) try: count = 0 while True: data = c.reserve(block=False) if not data: time.sleep(0.5) continue print data c.done() assert count + 1 == int(data) count = int(data) if int(data) == 500: break finally: c.close() zk.close()
def main(): zk = create_zk() c = Consumer(zk) try: count = None while True: data = c.reserve() if not data: break print data if count is None: count = int(data) else: assert count + 1 == int(data) count = int(data) c.done() finally: c.close() zk.close()
def child_main(): zk = create_zk() c = Consumer(zk) try: count = 0 while True: data = c.reserve(block = False) if not data: time.sleep(0.5) continue print data c.done() assert count + 1 == int(data) count = int(data) if int(data) == 500: break finally: c.close() zk.close()