title: Spawning multiple processes with Python
body: <p>Earlier I tried to use the <strong>threading</strong> module in python to create multiple threads. Then I learned about the <a href="https://stackoverflow.com/questions/1294382/what-is-a-global-interpreter-lock-gil">GIL</a> and how it does not allow taking advantage of multiple CPU cores on a single machine. So now I'm trying to do multiprocessing (I don't strictly need seperate threads).</p>
  
  <p>Here is a sample code I wrote to see if distinct processes are being created. But as can be seen in the output below, I'm getting the same process ID everytime. So multiple processes are not being created. What am I missing? </p>
  
  <pre><code>import multiprocessing as mp
  import os
  
  def pri():
      print(os.getpid())
  
  if __name__=='__main__':
  
      # Checking number of CPU cores
      print(mp.cpu_count())
  
      processes=[mp.Process(target=pri()) for x in range(1,4)]
  
      for p in processes:
          p.start()
  
      for p in processes:
          p.join()
  </code></pre>
  
  <p>Output:</p>
  
  <pre><code>4
  12554
  12554
  12554
  </code></pre>