Timeout function if it takes too long to finish
<p>I have a shell script that loops through a text file containing URL:s that I want to visit and take screenshots of.</p>

<p>All this is done and simple. The script initializes a class that when run creates a screenshot of each site in the list. Some sites take a very, very long time to load, and some might not be loaded at all. So I want to wrap the screengrabber-function in a timeout script, making the function return <code>False</code> if it couldn't finish within 10 seconds.</p>

<p>I'm content with the simplest solution possible, maybe setting a asynchronous timer that will return False after 10 seconds no matter what actually happens inside the function?</p>

<p>Ideas?</p>

<p>Thanks!</p>
