I have a python scripts that does some jobs. I use multiprocessing.Pool to have a few workers do some commands for me.
My problem is when I try to terminate the script. I would like when I press Ctrl-C, that every worker immediately cleans up it's experiment (which is some custom code, or actually even a subprocess command, not just releasing locks or memory) and stops.
I now that I can catch Ctrl-C with the signal handler. How can make all current running workers of a multiprocessing.Pool to terminate, still doing there cleanup command?
Pool.terminate() does of course not work, because the processes will be terminated without cleaning up.