kopia lustrzana https://github.com/micropython/micropython-lib
signal: Add example of signal handler in Python.
rodzic
28db583fa9
commit
ac136e6cf6
|
@ -0,0 +1,17 @@
|
||||||
|
import time
|
||||||
|
from signal import *
|
||||||
|
|
||||||
|
quit = 0
|
||||||
|
|
||||||
|
def handler(signum):
|
||||||
|
global quit
|
||||||
|
quit = 1
|
||||||
|
print('Signal handler called with signal', signum)
|
||||||
|
|
||||||
|
print("org signal() val:", signal(SIGINT, handler))
|
||||||
|
print("read back signal() val:", signal(SIGINT, handler))
|
||||||
|
|
||||||
|
while not quit:
|
||||||
|
time.sleep(10)
|
||||||
|
|
||||||
|
print("Quitting...")
|
Ładowanie…
Reference in New Issue