In reference to this question I had asked, I can successfully run jobs using multiprocessing and I can see that all processors are being utilized. How do I kill this job? From terminal I run:
python my_multiprocessor_script.py
Then I hit Ctrl+C
to kill.
However the job doesn't seem to be killed and I can see all the processors still in use. I'm running Red Hat Enterprise Linux Server release 6.6.
Alternatively, you can use the top command to find the python process. Simply enter k (for kill) and the top program will prompt you for the PID of the process to kill.
You can shutdown the process pool via the Pool. close() or Pool. terminate() functions.
Python provides a mutual exclusion lock for use with processes via the multiprocessing. Lock class. An instance of the lock can be created and then acquired by processes before accessing a critical section, and released after the critical section.
multiprocessing is a package that supports spawning processes using an API similar to the threading module. The multiprocessing package offers both local and remote concurrency, effectively side-stepping the Global Interpreter Lock by using subprocesses instead of threads.
You should be able to do something like this.
Original Author
kill -9 `ps -ef | grep my_multiprocessor_script.py | grep -v grep | awk '{print $2}'`
also take a look at Python Multiprocessing Kill Processes for more info
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With