How to return from function if got stuck for 90 seconds?
<blockquote>
  <p><strong>Possible Duplicate:</strong><br>
  <a href="http://stackoverflow.com/questions/492519/timeout-on-a-python-function-call">Timeout on a Python function call</a>  </p>
</blockquote>



<p>I want to implement that when the function took more than 90 seconds to complete it should return immediately when timeout. Is there any way to achieve that?</p>

<pre><code>def abc(string):
    import re
    if re.match('some_pattern', string):
        return True
    else:
        return False

abc('some string to match')
</code></pre>

<p><strong>Edited</strong></p>

<p>Please download <a href="http://dl.dropbox.com/u/37127032/t.py" rel="nofollow">this</a> test file. I have created a thread class and raise an exception within thread if timeout error occur. But thread is still alive because it prints <code>i am still alive :)</code> even after exception. Why an exception does not force the thread to stop?? </p>
