def host_online(host): t1 = time.time() while True: if ping_ok(host): break if (time.time() - t1) > PING_TIMEOUT: DWARN("host %s ping error" % (host)) return False DWARN("host %s ping lost, retry" % (host)) time.sleep(1) return True
def _ping(): while True: item = None try: item = q.get(block=False) except Queue.Empty, e: break if ping_ok(item): ok.append(item) else: error.append(item) q.task_done()