title: Handling interactive shells with Python subprocess
body: <p>I am trying to run multiple instances of a console-based game (dungeon crawl stone soup -- for research purposes naturally) using a multiprocessing pool to evaluate each run.  </p>
  
  <p>In the past when I've used a pool to evaluate similar code (genetic algorithms), I've used <code>subprocess.call</code> to split off each process.  However, with dcss being quite interactive having a shared subshell seems to be problematic.</p>
  
  <p>I have the code I normally use for this kind of thing, with crawl replacing other applications I've thrown a GA at.  Is there a better way to handle highly-interactive shells than this?  I'd considered kicking off a screen for each instance, but thought there was a cleaner way.  My understanding was that <code>shell=True</code> should be spawning a sub-shell, but I guess I it is spawning one in a way that is shared between each call.</p>
  
  <p>I should mention I have a bot running the game, so I don't want any actual interaction from the user's end to occur.</p>
  
  <pre><code># Kick off the GA execution
  pool_args = zip(trial_ids,run_types,self.__population)
  pool.map(self._GAExecute, pool_args)
  
  ---
  
  # called by pool.map 
  def _GAExecute(self,pool_args):
    trial_id       = pool_args[0]
    run_type       = pool_args[1]
    genome         = pool_args[2]
    self._RunSimulation(trial_id)
  
  # Call the actual binary
  def _RunSimulation(self, trial_id):
    command = "./%s" % self.__crawl_binary
    name    = "-name %s" % trial_id
    rc      = "-rc %s" % os.path.join(self.__output_dir,'qw-%s'%trial_id,"qw -%s.rc"%trial_id)
    seed    = "-seed %d" % self.__seed
    cdir    = "-dir %s" % os.path.join(self.__output_dir,'qw-%s'%trial_id)
  
    shell_command = "%s %s %s %s %s" % (command,name,rc,seed,cdir)
    call(shell_command, shell=True)
  </code></pre>