title: Killing or stopping an active thread
body: <p>I've come a long way and I'm almost there. I've converted from using Thread to Threading and can now switch videos mid-play, but I still am having trouble killing or stopping the first video. Basically, I'm making a video player controlled by buttons on a Raspberry Pi using OMXplayer. At the moment, I have to wait for one video to finish playing before pressing another button or else it will crash because multiple videos are playing at the same time.</p>
  
  <p>Thanks so much for any help you guys can offer.</p>
  
  <pre><code>#!/usr/bin/python
  
  import RPi.GPIO as GPIO
  import subprocess
  import threading
  import time
  
  GPIO.setmode (GPIO.BCM)
  GPIO.setwarnings (False)
  
  GPIO.setup(9, GPIO.IN)  # Button 1
  GPIO.setup(10, GPIO.IN) # Button 2
  
  def shoppingcart():
          global current_video
          while True:
                  if GPIO.input(9):
                          #current_video.terminate()
                          #current_video.kill()
                          print "Play Shoppingcart"
                          time.sleep(1)
                          current_video=subprocess.Popen(['omxplayer','-b','Desktop/videos/shoppingcart.mp4'],
                                          stdin=subprocess.PIPE,stdout=subprocess.PIPE,
                                          stderr=subprocess.PIPE,close_fds=True)
  
  def dodgeballs():
          global current_video
          while True:
                  if GPIO.input(10):
                          #current_video.terminate()
                          #current_video.kill()
                          print "Play Dodgeballs"
                          time.sleep(1)
                          current_video=subprocess.Popen(['omxplayer','-b','Desktop/videos/dodgeballs.mp4'],
                                          stdin=subprocess.PIPE,stdout=subprocess.PIPE,
                                          stderr=subprocess.PIPE,close_fds=True)
  
  v1 = threading.Thread( name='shoppingcart', target=shoppingcart ) # Videos thread
  v2 = threading.Thread( name='dodgeballs', target=dodgeballs )   # Videos thread
  
  v1.start()
  v2.start()
  
  while True:
          pass
  
  GPIO.cleanup() #Reset GPIOs
  </code></pre>