Python kill hanging function
<blockquote>
  <p><strong>Possible Duplicate:</strong><br>
  <a href="http://stackoverflow.com/questions/6468904/python-kill-hanging-function">Python kill hanging function</a>  </p>
</blockquote>



<p>I'm sure this has been asked before, but I can't find a similar example.  I need to be able to call a function with an execution time-limit.  If the function takes over this time, then the whole script exits.</p>

<p>This can't be done by timing the whole script! And I only want one, small function to be timed.  Is it possible?</p>

<p>For example</p>

<pre><code>    def sleep():
        time.sleep(60)

time("sleep()", limit=30, violation="sys.exit(1)")
</code></pre>

<p>Very basic and horrid looking example I know, but it might help the explanation.</p>
