def start(self):
    self.foo = subprocess.Popen(['a daemon service'])

def stop(self):
    self.foo.kill()
self.foo.wait()

def restart(self):
    self.start()
foo = foo_class()
foo.start()
time.sleep(5)
foo.stop()
How to kill a subprocess initiated by a different function in the same class