add signal handler

Solutions on MaxInterview for add signal handler by the best coders in the world

showing results for - "add signal handler"
Eve
16 May 2018
1import asyncio
2import signal
3
4def on_trap(loop,signum):
5    print(f"shlian on_trap:{signum}")
6    print("loop is stopping...")
7    loop.stop()
8    print("loop stopped")
9
10if __name__=="__main__":
11
12    loop=asyncio.get_event_loop()
13    loop.add_signal_handler(signal.SIGINT,on_trap,loop,signal.SIGINT)
14    loop.run_forever()
15
similar questions
queries leading to this page
add signal handler