title: Python: delete all celery workers
body: <p>I'd like to start and stop the celery worker processes from inside a Python script. I'm using Redis as the broker and backend.</p>
  
  <p>I issue a Popen command to start the workers from inside the script that schedules tasks for workers:</p>
  
  <pre><code>  # start the celery deamon
    cmd = 'celery worker '
    cmd += '--app intertext.tasks '
    cmd += '--loglevel critical'
    subprocess.Popen(shlex.split(cmd))
  </code></pre>
  
  <p>After all steps are complete, I want to delete all worker processes. I know I could do something like <code>ps -ef | grep celery | awk '{print $2}' | xargs kill -9</code> but that won't run on Windows.</p>
  
  <p>What's the best way to kill the processes opened with Popen (or the best way to start and stop the celery deamon from within a Python script)?</p>