title: Launch a single python script as different processes differing by command line arguments
body: <p>I have python script that takes command line arguments. The way I get the command line arguments is by reading a mongo database. I need to iterate over the mongo query and launch a different process for the single script with different command line arguments from the mongo query.</p>
  
  <p>Key is, I need the launched processes to be:</p>
  
  <ul>
  <li>separate processes share nothing</li>
  <li>when killing the process, I need to be able to kill them all easily.</li>
  </ul>
  
  <p>I think the command <code>killall -9 script.py</code> would work and satisfies the second constraint.</p>
  
  <p><strong>Edit 1</strong></p>
  
  <p>From the answer below, the <code>launcher.py</code> program looks like this</p>
  
  <pre><code>def main():
  
  
      symbolPreDict = initializeGetMongoAllSymbols()
      keys = sorted(symbolPreDict.keys())
  
      for symbol in keys:
              # Display key.
              print(symbol)
              command = ['python', 'mc.py', '-s', str(symbol)]
              print command
              subprocess.call(command)
  
  if __name__ == '__main__':
       main()
  </code></pre>
  
  <p>The problem is that <code>mc.py</code> has a call that blocks</p>
  
  <pre><code>receiver = multicast.MulticastUDPReceiver ("192.168.0.2", symbolMCIPAddrStr, symbolMCPort ) 
  while True: 
      try:
          b = MD()
  
          data = receiver.read() # This blocks
          ...
      except Exception, e:
          print str(e)
  </code></pre>
  
  <p>When I run the launcher, it just executes one of the <code>mc.py</code> (there are at least 39). How do I modify the launcher program to say "run the launched script in background" so that the script returns to the launcher to launch more scripts?</p>
  
  <p><strong>Edit 2</strong></p>
  
  <p>The problem is solved by replacing <code>subprocess.call(command)</code> with <code>subprocess.Popen(command)</code> </p>
  
  <p>One thing I noticed though, if I say <code>ps ax | grep mc.py</code>, the PID seem to be all different. I don't think I care since I can kill them all pretty easily with <code>killall</code>.</p>
  
  <p>[Correction] kill them with <code>pkill -f xxx.py</code></p>