def spawn_chimpd_submission_processor
      n = @concurrency/4
      n = 10 if n < 10
      Log.debug "Logging into API..."

      #
      # There is a race condition logging in with rest_connection.
      # As a workaround, do a tag query first thing when chimpd starts.
      #
      begin
        c = Chimp.new
        c.interactive = false
        c.quiet = true
        #c.tags = ["bogus:tag=true"]
        c.run
      rescue StandardError
      end

      puts "chimpd #{VERSION} launched with #{@concurrency} workers"

      Log.debug "Spawning #{n} submission processing threads"

      (1..n).each do |n|
        @threads ||=[]
        @threads << Thread.new {
          while true
            begin

              queued_request = @chimp_queue.pop
              group = queued_request.group
              queued_request.interactive = false
              tasks = queued_request.process
              tasks.each do |task|
                ChimpQueue.instance.push(group, task)
              end

            rescue StandardError => ex
                puts ex.backtrace
              Log.error " submission processor: group=\"#{group}\" script=\"#{queued_request.script}\": #{ex}"
            end
          end
        }
      end
    end
def spawn_chimpd_submission_processor
      n = @concurrency/4
      n = 10 if n < 10
      Log.debug "Logging into API..."

      #
      # There is a race condition logging in with rest_connection.
      # As a workaround, do a tag query first thing when chimpd starts.
      #
      begin
        c = Chimp.new
        c.interactive = false
        c.quiet = true
        #c.tags = ["bogus:tag=true"]
        c.run
      rescue StandardError
      end

      puts "chimpd #{VERSION} launched with #{@concurrency} workers"

      Log.debug "Spawning #{n} submission processing threads"

      (1..n).each do |n|
        @threads ||=[]
        @threads << Thread.new {
          while true
            begin

              queued_request = @chimp_queue.pop
              group = queued_request.group
              queued_request.interactive = false
              tasks = queued_request.process
              tasks.each do |task|
                ChimpQueue.instance.push(group, task)
              end

            rescue StandardError => ex
                puts ex.backtrace
              Log.error " submission processor: group=\"#{group}\" script=\"#{queued_request.script}\": #{ex}"
            end
          end
        }
      end
    end
Spawn threads to process submitted requests