title: How to execute a function in Python based on time provided by argument
body: <p>How to execute a function in Python based on time provided by seconds argument.</p>
  
  <pre><code>def timerfn(seconds, fn, *args):
      #start some timer
      #if function first launch is &gt; "seconds", abort
      #if function doing great.. repeat it and stop at "seconds"
  </code></pre>
  
  <p>As i'm thinking over it time.clock() can't really help here, because a function can be really tough and it will not ever reach a counter-timer to show some result or abort. </p>
  
  <p>Do i have to use threading module? i don't know much about threads, but from what i read - you can have only a one thread in work according to GIL, and this process really needs 2 threads at same time.. or some other trick that i don't know.</p>