I have been searching for a way to start and terminate a long-running \"batch jobs\" in python. Right now I\'m using \"os.system()\" to launch a long-running batch job insid
subprocess module is the proper way to spawn and control processes in Python.
from the docs:
The subprocess module allows you to spawn new processes, connect to their input/output/error pipes, and obtain their return codes. This module intends to replace several other, older modules and functions, such as:
os.system
os.spawn
os.popen
popen2
commands
so... if you are on Python 2.4+, subprocess
is the replacement for os.system
for stopping processes, check out the terminate()
and communicate()
methods of Popen
objects.