title: Detect if a process is already running and collaborate with it
body: <p>I'm trying to create a program that starts a process pool of, say, 5 processes, performs some operation, and then quits, but leaves the 5 processes open.  Later the user can run the program again, and instead of it starting new processes it uses the existing 5.  Basically it's a producer-consumer model where:</p>
  
  <ol>
  <li>The number of producers varies.</li>
  <li>The number of consumers is constant.</li>
  <li>The producers can be started at different times by different programs or even different users.</li>
  </ol>
  
  <p>I'm using the builtin <code>multiprocessing</code> module, currently in Python 2.6.4., but with the intent to move to 3.1.1 eventually.</p>
  
  <p>Here's a basic usage scenario:</p>
  
  <ol>
  <li>Beginning state - no processes running.</li>
  <li>User starts <code>program.py operation</code> - one producer, five consumers running.</li>
  <li>Operation completes - five consumers running.</li>
  <li>User starts <code>program.py operation</code> - one producer, five consumers running.</li>
  <li>User starts <code>program.py operation</code> - two producers, five consumers running.</li>
  <li>Operation completes - one producer, five consumers running.</li>
  <li>Operation completes - five consumers running.</li>
  <li>User starts <code>program.py stop</code> and it completes - no processes running.</li>
  <li>User starts <code>program.py start</code> and it completes - five consumers running.</li>
  <li>User starts <code>program.py operation</code> - one procucer, five consumers running.</li>
  <li>Operation completes - five consumers running.</li>
  <li>User starts <code>program.py stop</code> and it completes - no processes running.</li>
  </ol>
  
  <p>The problem I have is that I don't know where to start on:</p>
  
  <ol>
  <li>Detecting that the consumer processes are running.</li>
  <li>Gaining access to them from a previously unrelated program.</li>
  <li>Doing 1 and 2 in a cross-platform way.</li>
  </ol>
  
  <p>Once I can do that, I know how to manage the processes.  There has to be some reliable way to detect existing processes since I've seen Firefox do this to prevent multiple instances of Firefox from running, but I have no idea how to do that in Python.</p>