The Python Subprocess module is a highly flexible way of running background processes in Python. Here are two functions that show how to run external shell commands, one will wait for the command to return and the other runs in the background allowing the controlling script to stop it as required.
Passing unsanitized input to these functions will not end well.
"""Runs a bash command in the background, returns the Popen instance, does not block."""
return subprocess.Popen( [ cmd ], shell=True, executable='/bin/bash')
""" Runs an external command in bash, waits until the process has returned and returns output/ return code."""
proc = subprocess.Popen( [ cmd ], shell=True, executable='/bin/bash', stdout=subprocess.PIPE, stderr=subprocess.STDOUT )
return (proc.returncode, proc.stdout)