During a subprocess call, catch critical windows e

2019-09-19 11:20发布

"The application failed to initialize properly ... Click on OK,to terminate the application." is the message from the error pop-up. What is the way to catch these errors in Python code?

1条回答
欢心
2楼-- · 2019-09-19 11:59

Sounds familiar? This will block your subprocess.Popen forever.. until you click the 'OK' button. Add the following code to your module initialization to workaround this issue:

import win32api, win32con
win32api.SetErrorMode(win32con.SEM_FAILCRITICALERRORS |
                      win32con.SEM_NOOPENFILEERRORBOX)
查看更多
登录 后发表回答