alarm

Sound alarm when code finishes

Sound alarm when code finishes Question: I am in a situation where my code takes extremely long to run and I don’t want to be staring at it all the time but want to know when it is done. How can I make the (Python) code sort of sound an “alarm” when it is done? …

Total answers: 13

python: windows equivalent of SIGALRM

python: windows equivalent of SIGALRM Question: I have this decorator: def timed_out(timeout): def decorate(f): if not hasattr(signal, “SIGALRM”): return f def handler(signum, frame): raise TimedOutExc() @functools.wraps(f) def new_f(*args, **kwargs): old = signal.signal(signal.SIGALRM, handler) signal.alarm(timeout) try: result = f(*args, **kwargs) finally: signal.signal(signal.SIGALRM, old) signal.alarm(0) return result new_f.func_name = f.func_name return new_f return decorate The code only …

Total answers: 3