1

I have a flask application, which I need to restart sometimes. Currently I have to manually stop the flask server and restart it. Is there a way wherein I could assign name to flask server process, so that I could kill that process and then fire the python app.py command.

I need a way to kill only the flask server process. Currently the flask server process is shown as python process in windows task manager. I need a method to kill only one process and not other python processes.

I need a solution for windows system.

phileinSophos
  • 362
  • 4
  • 22
  • Maybe this : https://stackoverflow.com/a/2255466/9515831 – Victor Apr 24 '21 at 04:39
  • sorry, forgot to mention I am working on windows – phileinSophos Apr 24 '21 at 04:45
  • you could use this to get the pid of the process: https://unix.stackexchange.com/a/452056/435815, use this to kill the process: https://stackoverflow.com/a/17858114/13710015, and then you could use `subprocess.popen(shlex.split("python file.py"))`. You could then use something like pynput (https://stackoverflow.com/a/43106497/13710015) to stop the flask app and re-run it – KetZoomer Apr 24 '21 at 05:16
  • Take a look at https://stackoverflow.com/a/25130524/15239951 – Corralien Apr 24 '21 at 05:26

0 Answers0