from sys import stderr import time from httplib import HTTP from rand import choice urls = [ "/hzn12345", "/hzn00000", "/hzn54321", ] halfhour = 60 * 30 # in seconds t1 = time.time() n, f = 0, 0 while 1: u = choice(urls) conn = HTTP("brick", 8000) conn.putrequest("GET", u) conn.endheaders() errcode, errmsg, _ = conn.getreply() if errcode / 100 <> 3: stderr.write("unexpected reply: %s %s\n" % (errcode, errmsg)) f = f + 1 else: fp = conn.getfile() fp.read() fp.close() stderr.write("%s: %s\n" % (errcode, u)) n = n + 1 if time.time() - t1 > halfhour: break print "%s successful transactions, %s failed transactions" % (n,f)