1

I need to be able to call a async function in a signal when CTRL-C is pressed. I'm not sure how to do this.

Non working example:

async def close_handler(sig ,frame):
    global users
    print("exit")
    await closeProximityChat()
    writeUsers(users)
    sys.exit(0)

signal.signal(signal.SIGINT, await close_handler)
ThatBoi
  • 17
  • 5
  • 1
    Maybe the following will solution help https://stackoverflow.com/questions/48562893/how-to-gracefully-terminate-an-asyncio-script-with-ctrl-c – Martin Wehrle Dec 19 '20 at 19:02

0 Answers0