<s> import os , sys <EOL> from zkmq import ZooKeeper , Producer , Consumer <EOL> def create_zk ( ) : <EOL> quorum = "<STR_LIT>" "<STR_LIT>" <EOL> if '<STR_LIT>' in os . environ : <EOL> quorum = os . environ [ '<STR_LIT>' ] <EOL> return ZooKeeper ( quorum ) <EOL> def main ( zk ) : <EOL> p = Producer ( zk ) <EOL> p . put ( <NUM_LIT:1> , priority = <NUM_LIT:0> ) <EOL> p . put ( <NUM_LIT:2> , priority = <NUM_LIT:50> ) <EOL> p . put ( <NUM_LIT:3> ) <EOL> c = Consumer ( zk ) <EOL> try : <EOL> elements = [ ] <EOL> while True : <EOL> data = c . reserve ( ) <EOL> if data is None : break <EOL> elements . append ( int ( data ) ) <EOL> assert elements == [ <NUM_LIT:1> , <NUM_LIT:2> , <NUM_LIT:3> ] <EOL> print "<STR_LIT>" <EOL> finally : <EOL> c . close ( ) <EOL> if __name__ == '<STR_LIT:__main__>' : <EOL> zk = create_zk ( ) <EOL> try : <EOL> main ( zk ) <EOL> finally : <EOL> zk . close ( ) </s>
