def _timeout(self, timeout, handler, *args, **kw):
t = spawn_thread(target=handler, args=args, kw=kw)<EOL>t.daemon = True<EOL>t.start()<EOL>t.join(timeout)<EOL>if not t.is_alive():<EOL><INDENT>if t.exc_info:<EOL><INDENT>return t.exc_info<EOL><DEDENT>return t.result<EOL><DEDENT>else:<EOL><INDENT>try:<EOL><INDENT>msg = '<STR_LIT>'<EOL>raise RuntimeError(msg % t.name)<EOL><DEDENT>except:<EOL><INDENT>return sys.exc_info()<EOL><DEDENT><DEDENT>
Controls the time allocated for the execution of a method