📅  最后修改于: 2022-03-11 14:46:29.230000             🧑  作者: Mango
import asyncio
import signal
def on_trap(loop,signum):
print(f"shlian on_trap:{signum}")
print("loop is stopping...")
loop.stop()
print("loop stopped")
if __name__=="__main__":
loop=asyncio.get_event_loop()
loop.add_signal_handler(signal.SIGINT,on_trap,loop,signal.SIGINT)
loop.run_forever()