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.
I issue a Popen command to start the workers from inside the script that schedules tasks for workers:
  # start the celery deamon
  cmd = 'celery worker '
  cmd += '--app intertext.tasks '
  cmd += '--loglevel critical'
  subprocess.Popen(shlex.split(cmd))
After all steps are complete, I want to delete all worker processes. I know I could do something like ps -ef | grep celery | awk '{print $2}' | xargs kill -9 but that won't run on Windows.
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)?
 
    