for i in range(4):
    p = Process(target=f, args=(i, shared_array))
p.start()
processes.append(p)
try:
    for process in processes:
        process.join()
except KeyboardInterrupt:
    print('Keyboard interrupt in main')
for item in shared_array:
    pass
Прерывание клавиатуры с многопроцессорной обработкой Python