def __init__(self, max_buf_len, topic, timeout, encoding, compress, seq): self.max_buf_len = max_buf_len self.encoding = encoding cmpz = False if compress.lower() == "true": cmpz = True sequence=False if seq.lower() =="true": sequence=True self.tunnel = tunnel(topic, cmpz, timeout, sequence)
def __init__(self, max_buf_len, topic, timeout, encoding, compress, seq): self.max_buf_len = max_buf_len self.encoding = encoding cmpz = False if compress.lower() == "true": cmpz = True sequence = False if seq.lower() == "true": sequence = True self.tunnel = tunnel(topic, cmpz, timeout, sequence)
basepath = os.path.dirname(__file__) logging.config.fileConfig(basepath + "/../conf/log.conf") class PublishThread(threading.Thread): def __init__(self, t): self.id = id self.m = "aadfaddaffdf" self.t = t threading.Thread.__init__(self) def run(self): times = range(10) for i in times: time.sleep(1) post(self.t, self.m + str(i)) if __name__ == '__main__': use(passport("jiugao", "1111")) t = tunnel("t1") threads = [] threadnum = range(10) for i in threadnum: pt = PublishThread(t) pt.start() threads.append(pt) [t.join() for t in threads] release()