1

We are running a very large framework of python scripts for test 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?

2 Answers 2

2

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.

Sign up to request clarification or add additional context in comments.

5 Comments

Did you mean "uninterruptable"? Don't want to put words in your mouth. :)
I have inherited the framework (15-20k lines of code) so in time I might solve the issues with time outs.. were more looking for some magic key combination :)
And we are using the Pyro libs and I don't want to mess to much with that.
@Paul, Yet again, I am caught by mindless spellcheck accepting. :)
@StefanE, I know of no magic for this, and I'm certain if there is any it's not portable.
0

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

2 Comments

It's fairly certain that the issue is blocking calls not allowing the interpreter to raise KeyboardInterrupt, rather than catching and ignoring it.
Note that both of these instances should be used absurdly sparingly, at least if they don't come with a bare raise.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.