Python run system command and then exit… won't exit

前端 未结 4 866
悲&欢浪女
悲&欢浪女 2021-02-04 13:02

I have the following python code:

os.system(\"C:/Python27/python.exe C:/GUI/TestGUI.py\")
sys.exit(0)

It runs the command fine, and a window po

4条回答
  •  北恋
    北恋 (楼主)
    2021-02-04 13:35

    KeyboardInterrupts and signals are only seen by the process (ie the main thread). If your nested command hangs due to some kind of file read or write block, you won't be able to quit the program using any keyboard commands.

    Why does a read-only open of a named pipe block?

    If you can't eliminate the source of the disk block, then one way is to wrap the process in the thread so you can force kill it. But if you do this, you leave opportunity for half-written and corrupted files on disk.

提交回复
热议问题