title: How to get all messages in Amazon SQS queue using boto library in Python?
body: <p>I'm working on an application whose workflow is managed by passing messages in SQS, using boto.</p>
  
  <p>My SQS queue is growing gradually, and I have no way to check how many elements it is supposed to contain.</p>
  
  <p>Now I have a daemon that periodically polls the queue, and checks if i have a fixed-size set of elements. For example, consider the following "queue":</p>
  
  <pre><code>q = ["msg1_comp1", "msg2_comp1", "msg1_comp2", "msg3_comp1", "msg2_comp2"]
  </code></pre>
  
  <p>Now I want to check if I have "msg1_comp1", "msg2_comp1" and "msg3_comp1" in the queue together at some point in time, but I don't know the size of the queue.</p>
  
  <p>After looking through the API, it seems you can either get only 1 element, or a fixed number of elements in the queue, but not all:</p>
  
  <pre><code>&gt;&gt;&gt; rs = q.get_messages()
  &gt;&gt;&gt; len(rs)
  1
  &gt;&gt;&gt; rs = q.get_messages(10)
  &gt;&gt;&gt; len(rs)
  10
  </code></pre>
  
  <p>A suggestion proposed in the answers would be to get for example 10 messages in a loop until I get nothing back, but messages in SQS have a visibility timeout, meaning that if I poll elements from the queue, they won't be really removed, they will only be invisible for a short period of time.</p>
  
  <p>Is there a simple way to get all messages in the queue, without knowing how many there are?</p>