<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def query(self, domain, recordType, progress=True):
 """ Run the query Query spins out multiple thread workers to query each server @param domain: Domain to query @param recordType: Type of record to query for @param progress: Write progress to stdout @type domain: str @type recordType: str """


        # Ignore domain validation, if someone wants to lookup an invalid
        # domain let them, just ensure it's a string
        assert type(domain) == str, "Domain must be a string"

        # Ensure record type is valid, and in our list of allowed records
        recordType = recordType.upper()
        assert recordType in self.lookupRecordTypes, \
            "Record type is not in valid list of record types {0}". \
            format(', '.join(self.lookupRecordTypes))

        self.domain = domain
        self.recordType = recordType
        self.resultsColated = []
        self.results = []

        if len(self.serverList) == 0:
            logging.warning("Server list is empty. Attempting "
                            "to populate with prepareList")
            self.prepareList()

        logging.debug("Starting query against {0} servers".format(
            len(self.serverList)))

        workers = []
        startTime = datetime.utcnow()
        serverCounter = 0

        # Run continuously while waiting for results
        while len(self.results) < len(self.serverList):

            # Count the workers still running
            runningWorkers = len([w for w in workers if w.result is None])

            # Get the results of any finished workers
            for i, w in enumerate(workers):
                if w.result:
                    # Add the results and get rid of the worker from the
                    # worker list
                    self.results.append(w.result)
                    workers.pop(i)

            # Output progress
            if progress:
                # Output progress on one line that updates if terminal
                # supports it
                sys.stdout.write(
                    "\r\x1b[KStatus: Queried {0} of {1} servers, duration: {2}"
                    .format(len(self.results), len(self.serverList),
                            (datetime.utcnow() - startTime))
                )
                # Make sure the stdout updates
                sys.stdout.flush()

            # Start more workers if needed
            if runningWorkers < self.maxWorkers:
                logging.debug("Starting {0} workers".format(
                    self.maxWorkers - runningWorkers))

                # Start however many workers we need
                # based on max workers - running workers
                for i in range(0, self.maxWorkers - runningWorkers):
                    if serverCounter < len(self.serverList):

                        # Create a new thread with all the details
                        wt = QueryWorker()
                        wt.server = self.serverList[serverCounter]
                        wt.domain = domain
                        wt.recType = recordType
                        wt.daemon = True

                        # Add it to the worker tracker
                        workers.append(wt)

                        # Start it
                        wt.start()

                        serverCounter += 1

            # Pause a little bit
            time.sleep(0.1)

        # Now colate the results
        # Group by number of servers with the same response
        for r in self.results:
            # Result already in collation
            if r['results'] in [rs['results'] for rs in self.resultsColated]:
                cid = [
                    i for i, rs in enumerate(self.resultsColated)
                    if r['results'] == rs['results']
                ][0]

                self.resultsColated[cid]['servers'].append(r['server'])
            else:
                self.resultsColated.append(
                    {
                        'servers': [
                            r['server']
                        ],
                        'results': r['results'],
                        'success': r['success']
                    }
                )

        if progress:
            sys.stdout.write("\n\n")

        logging.debug("There are {0} unique results".format(
            len(self.resultsColated)))