def handle(self): print "%10.5f :: Handling request" % time.time() req = self.rfile.readline().strip() req = req.split(":") if req[1] == "log utility": print "%10.5f :: Log request" % time.time() slave_addr = tuple(req[-2:]) slave_ip = slave_addr[0] slave_port = slave_addr[1] log_info = req[2] try: with Utility.contextUtility(self.logUtility, log_info, evalFunc=bool, utilityCallback=self.explosionHandler, utilityCallbackArgs=[(slave_addr)]) as status: if not isinstance(status, Utility.UtilityError): print "%10.5f :: No Explosion Before :: slave->%s" %(time.time(), str(slave_addr)) except RuntimeError: print "\tSEE TODO: yield was never reached in the generator" #TODO: replace contexts with either wrappers or classes else: pass
def handle(self): print "%10.5f :: Handling request" % time.time() req = self.rfile.readline().strip() req = req.split(":") if req[1] == "log utility": print "%10.5f :: Log request" % time.time() slave_addr = tuple(req[-2:]) slave_ip = slave_addr[0] slave_port = slave_addr[1] log_writes = int(req[2]) timestamp = float(req[0]) print "WE GOT TIME:", timestamp try: with Utility.contextPreUtility(self.logUtility, timestamp, log_writes, evalFunc=bool, utilityCallback=self.explosionHandler, utilityCallbackArgs=[(slave_addr)]) as status: if not isinstance(status, Utility.UtilityError): print "%10.5f :: No Explosion Before :: slave->%s" %(time.time(), str(slave_addr)) except RuntimeError: # you should never see this.. you should check "status" for an exception print "\tSEE TODO: yield was never reached in the generator" else: pass
def monitorLog(self, log_file): with Utility.contextUtility(self.log_utility, evalFunc=bool, utilityCallback=self.log_callback) as status: while True: pass