class Hammer(threading.Thread): def __init__(self, hostname, op, num, threadNum): threading.Thread.__init__(self) self.conn = CachedHTTPConnection(hostname) self.op = op self.num = num self.threadNum = threadNum def run(self): if self.op == "insertDirect": sitename = "test" rrs = rapidrecsite.RapidRecSite(sitename) for j in range(self.num): if self.op == "insert": self.conn.post("/users/%s/items/%s/rating" % (randUsername(), randItemname()), randRating()) else: rrs.insert_relation( src_group="user", src_name=randUsername(), tgt_group="item", tgt_name=randItemname(), field="rating", value=randRating(), )
def __init__(self, hostname, op, num, threadNum): threading.Thread.__init__(self) self.conn = CachedHTTPConnection(hostname) self.op = op self.num = num self.threadNum = threadNum