Beh, almeno un mistero per me. Considera quanto segue:python timer mystery
import time
import signal
def catcher(signum, _):
print "beat!"
signal.signal(signal.SIGALRM, catcher)
signal.setitimer(signal.ITIMER_REAL, 2, 2)
while True:
time.sleep(5)
Funziona come previsto, consegna un "beat!" messaggio ogni 2 secondi. Successivamente, non viene prodotto alcun output:
import time
import signal
def catcher(signum, _):
print "beat!"
signal.signal(signal.SIGVTALRM, catcher)
signal.setitimer(signal.ITIMER_VIRTUAL, 2, 2)
while True:
time.sleep(5)
Dov'è il problema?
Hai provato a cambiare 'time.sleep (5)' nel secondo programma in 'pass'? – Gabe