def run(self): count = 0 while count < NUM_SENDS: time.sleep(SEND_RATE) self.log.critical("Stu sending stab") stab = Stab.from_data("stab #{}".format(count)) self.parent.reactor.pub(url=URL2, data=Envelope.create(stab)) count += 1
def recv_poke_req(self, poke: PokeRequest, id): self.log.critical("Stu got poke {}, but waiting {} seconds...".format(REPLY_WAIT)) time.sleep(REPLY_WAIT) self.log.critical("Stu replying to poke <{}> with id {}".format(poke, id)) reply = PokeReply.from_data("yoyo this is my reply to {}".format(poke)) stab = Stab.from_data("stab!") self.parent.reactor.pub(url=URL2, data=Envelope.create(stab)) return reply
def send_poke(self, poke_msg): poke = Poke.from_data(poke_msg) evl = Envelope.create(poke) self.reactor.pub(url=self.url, data=evl.serialize())