How can I make my Python script only run for 10 seconds?
This question is an extremely popular one. It never gets a straightforward answer - because even though it sounds like a simple and obvious thing to ask, it is not well thought out.
What exactly should happen if the program is in the middle of something important when the time is up? When exactly is it allowed to quit? If there was some complex calculation in progress, what should happen when it is stopped - is there any meaningful way to show partial results, for example?
So I’m thinking that if the time runs out, the script will pick up where it left off (which creates more risks/problems). Also, if I know the average of how many seconds it should run, but the time runs out, then it will indicate that something is wrong, right?
Thank you very much.