def main(args): if len(args) < 1 or args[0] in ["?", "-?", "help", "-help", "--help"]: print __doc__ sys.exit(0) operation = args[0] if operation not in VALID_OPERATIONS: print __doc__ sys.exit(0) # conn = linuxtuples.connect("desktop", 27000) conn = linuxtuples.connect() if operation == "log": doLogging(conn) elif operation == "dump": doDump(conn) elif operation == "size": print conn.count() elif operation == "jobs": for tup in conn.dump([("job running", None, None, None)]): print tup elif operation == "empty": empty_tuple_space(conn) elif operation == "start": name = args[1] count = int(args[2]) doStart(conn, name, count) elif operation == "stop": doStop(conn) elif operation == "test": doTest(conn)
# $ ./pingpong.py tic toe # $ ./pingpong.py tac tic # $ ./pingpong.py toe tac # import sys import os import time import linuxtuples if len(sys.argv) != 3 : print "Usage:", sys.argv[0], "have want" sys.exit(1) conn = linuxtuples.connect() counter = 0 h = sys.argv[1] w = sys.argv[2] have=h want=w for i in range(1000) : conn.put((have, counter)) rv=conn.get((want, None)) if not i : time0 = os.times()[4] counter += 1
# Also, n-way pongs are possible # $ ./pingpong.py tic toe # $ ./pingpong.py tac tic # $ ./pingpong.py toe tac # import sys import os import time import linuxtuples if len(sys.argv) != 3: print "Usage:", sys.argv[0], "have want" sys.exit(1) conn = linuxtuples.connect() counter = 0 h = sys.argv[1] w = sys.argv[2] have = h want = w for i in range(1000): conn.put((have, counter)) rv = conn.get((want, None)) if not i: time0 = os.times()[4] counter += 1