title: How to continuously flash LED (or other while loop) while Python code continues to run
body: <p>I would like to be able to flash an LED continuously while my main <code>while</code> loop continues. I understand that in the following code when the function <code>led_flash()</code> gets called, the script will stop until the <code>while</code> loop defined in the function ends. This prohibits the remainder of the code from running. </p>
  
  <pre><code>import RPi.GPIO as GPIO
  import time
  
  GPIO.setmode(GPIO.BCM)
  GPIO.setup(25, GPIO.OUT)
  
  def led_flash():
      while TRUE:
          GPIO.output(25, ON)
          time.sleep(1)
          GPIO.output(25, OFF)
          time.sleep(1)
  
  while True:
      if x=1
          led_flash()
          ...do other stuff
  </code></pre>
  
  <p>I have read that threading will work in this instance, however I have not found an example simple enough for me to grasp. Additionally, if threading, how would I be able to end the <code>led_flash()</code> function thread later in my main <code>while</code> loop?</p>