title: How to write a polling function in Python?
body: <p>I am trying to write a function that reads the variable every 1 minute and return the value of each time. The variable name is proc:</p>
  
  <pre><code>proc = subprocess.Popen(['sshpass', '-p', password, 'rsync', '-avz', '--info=progress2', source12, destination], 
                                      stderr=subprocess.PIPE, stdout=subprocess.PIPE).communicate()[0]
  </code></pre>
  
  <p>The progress is stored in proc variable. I want the function to poll the variable every 1 minute and return value. This is done until the variable is upon execution. What's the best way to do it?</p>
  
  <p>Tried using:</p>
  
  <pre><code>def doWork():
      while True:
          proc = subprocess.Popen(['sshpass', '-p', password, 'rsync', '-avz', '--info=progress2', source12, destination], 
                                      stderr=subprocess.PIPE, stdout=subprocess.PIPE).communicate()[0]stdout=subprocess.PIPE).communicate()[0]
          data = sort(proc)
          print data 
          time.sleep(10)
  </code></pre>
  
  <p>No luck though! It prints the entire progress at same time and loop over. </p>