def stop_if_signal_caught
      Thread.new do
        loop do
          sleep 1

          if @shutdown
            logger.info "Recevied SIG#{@shutdown}, shutting down consumers"

            @consumer_instances.each { |instance| instance.shutdown }

            @client.channel.work_pool.shutdown
            @shutdown = nil
          end
        end
      end
    end
def stop_if_signal_caught
      Thread.new do
        loop do
          sleep 1

          if @shutdown
            logger.info "Recevied SIG#{@shutdown}, shutting down consumers"

            @consumer_instances.each { |instance| instance.shutdown }

            @client.channel.work_pool.shutdown
            @shutdown = nil
          end
        end
      end
    end
Checks for presence of @shutdown every 1 second and if found instructs
 all the channel's work pool consumers to shutdown. Each work pool thread
 will finish its current task and then join the main thread. Once all the
 threads have joined then `channel.work_pool.join` will cease blocking and
 return, causing the process to terminate.