title: How can I run a certain function for a specific time in Python?
body: <p>For example i have function do_something() and I want it to run for exactly 1 second (and not .923 seconds. It won't do. However 0.999 is acceptable.)</p>
  
  <p>However it is very very important that the <code>do_something</code> must exactly run for 1 second. I was thinking of using UNIX time stamp and calculate the seconds. But I am really wondering if Python has a way to do this in a more aesthetic way... </p>
  
  <p>The function <code>do_something()</code> is long-running, and must be interrupted after exactly one second.</p>