title: Stop opening VLC in python
body: <p>I wrote a little code which scans the wifi signals in the air and according to the amount plays one or another audio file. <br><br></p>
  
  <pre><code>import time
  import subprocess
  import os
  
  while True:
      output = subprocess.Popen("airport en1 -s", shell=True, stdout=subprocess.PIPE).stdout.read()
      lines = output.split('\n')
      n = len(lines)
      if n &lt; 10:
          print os.path.exists('/Users/shirin/Desktop/wifi/1.mp3') 
          p = subprocess.Popen(['/Applications/VLC.app/Contents/MacOS/VLC','/Users/shirin/Desktop/wifi/1.mp3'])
      elif n &gt; 10:
          print os.path.exists('/Users/shirin/Desktop/wifi/1.mp3') 
          p = subprocess.Popen(['/Applications/VLC.app/Contents/MacOS/VLC','/Users/shirin/Desktop/wifi/1.mp3'])
  </code></pre>
  
  <p>Now my problem is that, when I run the file through the terminal it keeps running the code over and over again and I do not know how to stop it. It also does not stop when I close the terminal. 
  So my question:
  How can I tell python to run the code once and then stop?
  <br><br>
  already super thanks!</p>