We are running a very large framework of python scripts for t开发者_如何转开发est automation and I do really miss the opportunity to kill a running python script with ctrl + c in some situations on Windows.
When the script might be doing some socket communications with long time-outs the only options sometimes is to kill the DOS window.. Is there any options I have missed?
Rather than using blocking calls with long timeouts, use event-driven networking. This will allow you never to have long periods of time doing uninterruptable operations.
Look for instances of:
try:
some code
except:
# catches all exceptions, including ^C
Change to:
try:
some code
except Exception:
# catches most exceptions, but not KeyboardInterrupt or SystemExit
精彩评论