¿Cómo capturo SIGINT en Python?
Estoy trabajando en un script de Python que inicia varios procesos y conexiones de base de datos. De vez en cuando quiero matar el guión con unCtrl+C Señal, y me gustaría hacer un poco de limpieza.
En Perl haría esto:
$SIG{'INT'} = 'exit_gracefully';
sub exit_gracefully {
print "Caught ^C \n";
exit (0);
}
¿Cómo hago el análogo de esto en Python?