title: Python multiprocessing - Is it possible to introduce a fixed time delay between individual processes?
body: <p>I have searched and cannot find an answer to this question elsewhere. Hopefully I haven't missed something.</p>
  
  <p>I am trying to use Python multiprocessing to essentially batch run some proprietary models in parallel. I have, say, 200 simulations, and I want to batch run them ~10-20 at a time. My problem is that the proprietary software crashes if two models happen to start at the same / similar time. I need to introduce a delay between processes spawned by multiprocessing so that each new model run waits a little bit before starting.</p>
  
  <p>So far, my solution has been to introduced a random time delay at the start of the child process before it fires off the model run. However, this only reduces the probability of any two runs starting at the same time, and therefore I still run into problems when trying to process a large number of models. I therefore think that the time delay needs to be built into the multiprocessing part of the code but I haven't been able to find any documentation or examples of this.</p>
  
  <p>Edit: I am using Python 2.7</p>
  
  <p>This is my code so far:</p>
  
  <pre><code>from time import sleep
  import numpy as np
  import subprocess
  import multiprocessing
  
  def runmodels(arg):
      sleep(np.random.rand(1,1)*120) # this is my interim solution to reduce the probability that any two runs start at the same time, but it isn't a guaranteed solution
      subprocess.call(arg) # this line actually fires off the model run
  
  if __name__ == '__main__':    
  
      arguments =     [big list of runs in here
                      ]    
  
      count = 12
      pool = multiprocessing.Pool(processes = count)
      r = pool.imap_unordered(runmodels, arguments)      
      pool.close()
      pool.join()
  </code></pre>