<commit_before>require 'json'
require 'sqs'
require 'timeout'

module Tootsie
  
  class SqsQueueCouldNotFindQueueError < Exception; end

  # A queue which uses Amazon's Simple Queue Service (SQS).
  class SqsQueue
    
    def initialize(queue_name, access_key_id, secret_access_key)
      @sqs_service = ::Sqs::Service.new(
        :access_key_id => access_key_id,
        :secret_access_key => secret_access_key)
      @logger = Application.get.logger
      @queue = @sqs_service.queues.find_first(queue_name)
      unless @queue
        @sqs_service.queues.create(queue_name)
        begin
          timeout(5) do
            while not @queue
              sleep(0.5)
              @queue = @sqs_service.queues.find_first(queue_name)
            end<commit_msg>Longer timeout when waiting for SQS queue creation.<commit_after>require 'json'
require 'sqs'
require 'timeout'

module Tootsie
  
  class SqsQueueCouldNotFindQueueError < Exception; end

  # A queue which uses Amazon's Simple Queue Service (SQS).
  class SqsQueue
    
    def initialize(queue_name, access_key_id, secret_access_key)
      @sqs_service = ::Sqs::Service.new(
        :access_key_id => access_key_id,
        :secret_access_key => secret_access_key)
      @logger = Application.get.logger
      @queue = @sqs_service.queues.find_first(queue_name)
      unless @queue
        @logger.info "Queue #{queue_name} does not exist, creating it"
        @sqs_service.queues.create(queue_name)
        begin
          timeout(30) do
            while not @queue
              sleep(1)
              @queue = @sqs_service.queues.find_first(queue_name)
            end
{'fraction_non_alphanumeric': 0.08547008547008547, 'fraction_numerical': 0.003663003663003663, 'mean_word_length': 2.7505720823798625, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3806921', 'n_tokens_mistral': 520, 'n_tokens_neox': 509, 'n_words': 114}