title: Clean Python multiprocess termination dependant on an exit flag
body: <p>I am attempting to create a program using multiple processes and I would like to cleanly terminate all the spawned processes if errors occur. below I've wrote out some pseudo type code for what I think I need to do but I don't know what the best way is to communicate to all the processes that an error has occured and they should terminate. </p>
  
  <p>I think I should be using classes for this sort of thing but I'm quite new to Python so I'm just trying to get my head around the basics first. </p>
  
  <pre><code>#imports
  
  exitFlag = True
  
  # Function for threads to process   
  def url_thread_worker( ):   
  # while exitFlag:
      try:
          # do something
      except:
          # we've ran into a problem, we need to kill all the spawned processes and cleanly exit the program
          exitFlag = False
  
  def processStarter( ):
  
      process_1 = multiprocessing.Process( name="Process-1", target=url_thread_worker, args=( ) ) 
      process_2 = multiprocessing.Process( name="Process-2", target=url_thread_worker, args=( ) ) 
  
      process_1.start()
      process_2.start()
  
  
  if __name__ == '__main__':
       processStarter( )
  </code></pre>
  
  <p>Thanks in advance</p>