title: Processing SQS queues with boto
body: <p>I have a python script using the boto library on ec2 instance which is part of an autoscaling group. The script processes messages from a SQS queue:</p>
  
  <pre><code>import boto
  from boto.sqs.message import Message
  
  conn = boto.connect_sqs()
  q = conn.create_queue('queue-name')
  
  while (qin.count() &gt; 0):
      m = q.get_messages()
      #do something with the message
  </code></pre>
  
  <p>Does using the while statement make sense? Does count() update in real time as:</p>
  
  <ol>
  <li>other instances take messages off the queue (or am I going to double up)</li>
  <li>new messages are added to the queue (or will I miss them?)</li>
  </ol>
  
  <p><strong>How do I make this script constantly listen for new additions to the queue, even while the queue is empty?</strong> </p>
  
  <p>In this question <a href="https://stackoverflow.com/questions/8203531/processing-items-in-sqs-queue-with-a-php-script">Processing items in SQS queue with a php script</a> it was mentioned that 'sqs ruby client library has a method "poll" which continuously polls the queue and on receiving a message in the queue passes it on to a block'. Is there an equivalent in Python?</p>
  
  <p>It has also been suggested that the SNS could be used to notify the scripts of the message queue status but I do not see how you could configure a responsive system with SNS as the metric alarms are not fine grained enough.</p>