tags:

views:

83

answers:

2

Starting a Perl script with alarm(3600) will make the script abort if it is still running after one hour (3600 seconds).

Assume I want to set an upper bound on the running time of a Python script, what is the easiest way to achieve that?

+2  A: 

on Unix you could use signal.alarm.

SilentGhost
Thanks! signal.alarm did the trick!
knorv
+1  A: 

Just for your information: this is much self-descriptive to use multiplication when you set up timers, for example alarm(24 * 60 * 60) for 24 hours, instead of alarm(86400) for the same period. Hope this will help keep your code clean and easy-maintainable :)

Dr. Noise
Good point! Tip: Your answer should probably be made as a comment instead of an answers, since you're commenting the question rather than providing an answer. Thanks anyway!
knorv