def list_stats(l): stats = '\tsamples:%s' % len(l) stats += '\taverage:%s' % timefmt(average(l)) stats += '\tstddev:%s' % timefmt(standard_dev(l)) stats += '\tmax:%s' % max(l) stats += '\tmin:%s' % min(l) return stats
def reconnect(self, after=10, timeout=None, nolog=False): """ reconnect to the host:: after how long to wait for the first attempt timeout how long to wait for each attempt """ # default to this instance's current value if timeout is None: timeout = self.timeout self.close() start = now() while 1: sleep(after) try: if self.connect(timeout=timeout, nolog=nolog): break except (TIMEOUT, EOF) as e: self.close() if not nolog: logger.debug(str(e)) logger.debug("reconnected after %s" % timefmt(since(start))) return True