Estou testando o threading Python com o seguinte script:
import threading
class FirstThread (threading.Thread):
def run (self):
while True:
print 'first'
class SecondThread (threading.Thread):
def run (self):
while True:
print 'second'
FirstThread().start()
SecondThread().start()
Ele está sendo executado no Python 2.7 no Kubuntu 11.10. Ctrl+ Cnão vai matá-lo. Também tentei adicionar um manipulador para sinais do sistema, mas isso não ajudou:
import signal
import sys
def signal_handler(signal, frame):
sys.exit(0)
signal.signal(signal.SIGINT, signal_handler)
Para matar o processo estou eliminando-o por PID após enviar o programa para segundo plano com Ctrl+ Z, que não está sendo ignorado. Por que Ctrl+ está Csendo ignorado tão persistentemente? Como posso resolver isto?