我尝试捕获键盘中断并在用户选择使用以下代码恢复进程后恢复:
except KeyboardInterrupt:
q = prompt("CNTRL-C was pressed what would you like to do", "quit(q)/pause(p)")
if q.lower().startswith("q"):
shutdown(0)
elif q.lower().startswith("p"):
LOGGER.warning("Application will pause until a key is pressed..")
try:
os.system("pause")
except:
os.system("read -p")
else:
shutdown(0) # shut down is just exit with a log message
然而,似乎每当我按下键继续后我尝试这样做时,它就会退出该过程:
[*] Starting up at: 1498843527.18..
[12:25:27 INFO] Using algorithm, MSSQL 2000..
[12:25:27 PROMPT] CNTRL-C was pressed what would you like to do[quit(q)/pause(p)]: p
[12:25:28 WARNING] Application will pause until a key is pressed..
Press any key to continue . . .
如何让程序记住我在做什么,然后在用户决定之后恢复相同的过程?