def healthy(self, now=0, timeout=0): """Report if a connection is healthy. If a connection should be removed then return false. An optional now argument is provided to give the current time.""" # did we lose the connection if self.fileno() < 0: log("lost connection with " + str(self)) return 0 # make sure we know the current time if not now: now = time.time() if not timeout: timeout = self.IdleTimeout # when was the last message received if timeout and (now - self.lastmsg) > timeout: log(str(self) + " was idle for more than %d seconds, " \ "removing" % timeout) return 0 return 1
def printTraceback(msg=None): """Prints the current error stack to stderr.""" if msg: log(msg) log("printing traceback") traceback.print_exc() log("end traceback")
def dprintUrl(self, url): """Display url when running in debug mode.""" if self.debug: progutil.log( "[%s:%s] http://%s:%s/Tractor/%s" % (self.hostname, self.port, self.hostname, self.port, url))
def dprint(self, msg): """Display message when running in debug mode.""" if self.debug: progutil.log("[%s:%s] %s" % (self.hostname, self.port, msg))
def dprintUrl(self, url): """Display url when running in debug mode.""" if self.debug: progutil.log("[%s:%s] http://%s:%s/Tractor/%s" % (self.hostname, self.port, self.hostname, self.port, url))