I've got a python script which maps in multiprocessing a function with a list of input.
import multiprocessing as mp
L = [(x1, y1), (x2, y2), ...]
with mp.Pool(processes = N) as p:
p.starmap(f, L)
I would like to have a way to shutdown properly the program.
The idea would be to have a key to hit, "Q" for instance, or "Ctrl+Q" that would then stop all the processes at the end of the current iteration. In single threading program, I usually interrupt with Ctrl+C.
Can this be done in python?
Thanks :)
N.B: Python version 3.6