You can use "alarm" to produce an error after a certain number of
seconds and use "try" to ensure that the program continues. Sadly,
there is currently no way to distinguish an alarm error from any other
kind of error. Another approach would be to start another M2 process
with a time limit. When threads are implemented well, that will be
another way to go.