def report_idle_after(seconds):
def decorator(func):<EOL><INDENT>def wrapper(*args, **kwargs):<EOL><INDENT>def _handle_timeout(signum, frame):<EOL><INDENT>config = get_config()<EOL>if not config.ready:<EOL><INDENT>config.load()<EOL><DEDENT>message = {<EOL>"<STR_LIT>": "<STR_LIT>",<EOL>"<STR_LIT:body>": idle_template.format(<EOL>app_id=config.get("<STR_LIT:id>"), minutes_so_far=round(seconds / <NUM_LIT>)<EOL>),<EOL>}<EOL>log("<STR_LIT>")<EOL>get_messenger(config).send(message)<EOL><DEDENT>signal.signal(signal.SIGALRM, _handle_timeout)<EOL>signal.alarm(seconds)<EOL>try:<EOL><INDENT>result = func(*args, **kwargs)<EOL><DEDENT>finally:<EOL><INDENT>signal.alarm(<NUM_LIT:0>)<EOL><DEDENT>return result<EOL><DEDENT>return wraps(func)(wrapper)<EOL><DEDENT>return decorator<EOL>
Report_idle_after after certain number of seconds.