title: Stopping a thread once condition matches
body: <p>I want to trigger <code>upfunction</code> and stop when it writes 3 in the filename. Basically I want to stop a thread once the condition is met as shown below. </p>
  
  <pre><code>def getstatus():
      fh = open(filename,'r')
      return fh.read()
  
  def  upfunction(arg):
  
      for i in range(arg):
          print ("backup running")
          print(getstatus())
          target = open(filename, 'w')
          target.write(str(i))
          sleep(1)
  
  
  
  if __name__ == "__main__":
      thread = Thread(target = upfunction, args = (10, ))
      thread.start()
      print(getstatus())
      while getstatus() != "3":
          print("NOT 3 ")
          sleep(0.5)
          continue
  
  
      thread.stop()
      print("thread finished...exiting")
  </code></pre>
  
  <p>It shows </p>
  
  <blockquote>
    <p>AttributeError: 'Thread' object has no attribute 'stop'</p>
  </blockquote>
  
  <p>Please see me as newbie to python. 
  Any help will be highly appreciated </p>