What is the best practice for restarting an ubuntu system service from within a python program? The service is responsible for starting the same program where the restart would be called from. The service script has stop,start and restart methods. The stop method is supposed to kill the running processes originally executed in the start method. I have been using subprocess.call method in python however the program has a Flask session and when I call restart on the program the scripts began execution but I get an "Address already in use error" indicating that the flask session has not been ended.
Similar question: Python spawn off a child subprocess, detach, and exit