예제 #1
0
    def next_host(self):
        """
        Getting next hostname from the appropriate queue.

        :return str: hostname e.g. "google.com"
        """
        if self._counter > 0 and self._counter % self._dump_threshold == 0:
            Dumper.dump_counter(self._counter)

        if self._result_queue.qsize() >= self._result_queue_threshold:
            print("result_queue full, check if result_worker is running")
            return None, None

        if not self._user_queue.empty():
            # Trap for prioritizing the user_queue
            return self._user_queue.get()

        try:
            hostname = self._host_queue.get(timeout=3)
        except Empty:
            return None, None

        with self._filling_condition:
            while self._is_filling:
                self._filling_condition.wait()

        # cycle queue
        self._host_queue.put(hostname)

        # checking if new list is available
        self.put_new_list(self._new_list_holder)

        # keep track by counting
        self._counter += 1

        # Keep track of how many times the host_queue has been "parsed" by sslyze
        if self._counter == self._host_queue.qsize():
            self._counter = 0
            self._times_fully_parsed += 1

        return hostname, None