def reverse_dns_preheat()

in cstar/job.py [0:0]


    def reverse_dns_preheat(self, ips):
        if self.is_preheated:
            return
        self.is_preheated = True

        def get_host_by_addr(ip):
            try:
                socket.gethostbyaddr(ip)
            except socket.herror:
                pass

        def create_lookup_thread(ip):
            return threading.Thread(target=lambda: get_host_by_addr(ip))

        print("Preheating DNS cache")
        threads = [create_lookup_thread(ip) for ip in set(ips)]

        for thread in threads:
            thread.start()

        for thread in threads:
            # Don't wait around forever for slow DNS
            thread.join(1.0)
        print("Preheating done")