def process_queued_commands(self, ):
        """
        See if any active mailboxes have queued commands that still need to be
        processed and let them run if they do.
        """
        # Some IMAP clients can be nasty with the number of commands they have
        # running in parallel. Also you may have gobs of IMAP clients. In these
        # cases we want to make sure we still pull messages off of the network
        # socket without blocking for too long (5 seconds to actually read a
        # message is probably too long.)
        #
        # When we are processing queued messages they are popped off the front
        # of the command queue, and then if they need to be continued, pushed
        # on to the back of the command queue.
        #
        # What we do is generate a randomized list of mailboxes that have
        # queued commands. We then run through that list of mailboxes once,
        # doing one queued command from each mailbox or until a maximum of <n>
        # (5?) seconds has passed.
        #
        # Since the list of mailboxes is randomized each time we are called and
        # each time we run a queued command we stick it back on to the _end_ of
        # the command queue this should generally work through the queued
        # commands in a fair fashion.
        #
        mboxes = [x for x in self.active_mailboxes.values()
                  if x.has_queued_commands()]
        if len(mboxes) == 0:
            return
        start_time = time.time()

        num_queued_cmds = sum(len(x.command_queue) for x in mboxes)
        self.log.debug("process_queued_command: ** START Number of queued "
                       "commands: %d" % num_queued_cmds)

        random.shuffle(mboxes)

        for mbox in mboxes:
            if len(mbox.command_queue) == 0:
                continue
            self.log.debug("process_queued_command:    mbox: %s - commands in "
                           "queue: %d" % (mbox.name,
                                          len(mbox.command_queue)))
            client, imap_cmd = mbox.command_queue.pop(0)

            # If the client's network connectionis closed then we do not
            # bother processing this command.. there is no one to receive
            # the results.
            #
            if not client.client.connected:
                continue

            try:
                self.log.debug("process_queued_command mbox: %s, client: "
                               "%s, cmd: %s" % (mbox.name, client.name,
                                                str(imap_cmd)))
                client.command(imap_cmd)
            except Exception:
                # We catch all exceptions and log them similar to what
                # asynchat does when processing a message.
                #
                nil, t, v, tbinfo = asyncore.compact_traceback()
                self.log.error("Exception handling queued command: "
                               "%s:%s %s" % (t, v, tbinfo))

            # If we have been processing queued commands for more than n (5?)
            # seconds that is enough. Return to let the main loop read more
            # stuff from clients.
            #
            now = time.time()
            if start_time - now > 5:
                self.log.debug("process_queued_command: ** Running for %f "
                               "seconds. Will run more commands later" %
                               (now - start_time))
                return

        now = time.time()
        self.log.debug("process_queued_command: ** Finished all queued "
                       "commands. Took %f seconds" % (now - start_time))

        return

    ##################################################################
    #
dataset/ETHPy150Open scanner/asimap/asimap/user_server.py/IMAPUserServer.process_queued_commands/swapped operands of `-`