signal: Add example of signal handler throwing exception.

pull/26/head
Paul Sokolovsky 2015-03-11 22:44:52 +02:00
rodzic 4e51698e4b
commit 1cdaf050c8
1 zmienionych plików z 21 dodań i 0 usunięć

Wyświetl plik

@ -0,0 +1,21 @@
import time
from signal import *
quit = 0
def handler(signum):
global quit
# quit = 1
print('Signal handler called with signal', signum)
raise OSError("Couldn't open device!")
print("org signal() val:", signal(SIGINT, handler))
print("read back signal() val:", signal(SIGINT, handler))
try:
while not quit:
time.sleep(10)
except:
print("Caught exc")
print("Quitting")