title: How can use the Process class of Pythons Multiprocessing library to run a function multiple times?
body: <p>I've got a function that simulates a stochastic system of chemical reactions. I now want to use the Process class from Pythons Multiprocessing library to run the stochastic simulation function several times.</p>
  <p>I tried the following:</p>
  <pre><code>v = range(1, 51)
  def parallelfunc(v):     
      gillespie_tau_leaping(start_state, LHS, stoch_rate, state_change_array)
  
  
  if __name__ == '__main__':
      start = datetime.utcnow()
      p = Process(target=parallelfunc, args=(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50))
      p.start()    
      p.join()
      end = datetime.utcnow()
      sim_time = end - start
      print(f&quot;Simualtion utc time:\n{sim_time}&quot;)
  </code></pre>
  <p>but this results in the error <code>TypeError: parallelfunc() takes 1 positional argument but 50 were given</code></p>
  <p>Then i tried just passing <code>range(1, 51)</code> to both <code>parallelfunc</code> and the <code>args</code> parameter of process but then I just get <code>SyntaxError: invalid syntax</code> on the deceleration of <code>parallelfunc</code></p>
  <p>The method of using a function like <code>parallelfunc</code> in this way works when using <code>pool.map</code> there I just pass <code>parallelfunc</code> followed by a list from 1 - 50.</p>
  <p>But I can't figure out whats going wrong here.</p>
  <p>Any suggestions
  Cheers.</p>