-1

I have a program that will do some machine learning predictions while at the same time monitors the computer resources that are being used (CPU, RAM, Disk I/O) using PSUtil module. I split them into two different programs; predict.py and monitor.py

The goal is when the predict.py starts, monitor.py starts. The monitor.py won't stop unless the predict.py has done working. I've done my research and found threading. However, when I had a try on that, it did not work. Is there any easy way to do this?

  • Does this answer your question? [Python spawn off a child subprocess, detach, and exit](https://stackoverflow.com/questions/5772873/python-spawn-off-a-child-subprocess-detach-and-exit) – Peter Badida Jul 07 '21 at 07:11
  • 1
    I don't think Python threads run concurrently. It sounds like you want to run an independent process rather than a thread. – Tom Karzes Jul 07 '21 at 07:12
  • You could also give a try to this answer [linux - Python: how to kill child process(es) when parent dies?](https://stackoverflow.com/a/23436111/3074151) – qba-dev Jul 07 '21 at 07:36

1 Answers1

0

hello you can print "monitor.py" into end of predict.py and use this command to run them

python monitor.py & pkill $(python predict.py)