signal-handling

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

Python – Trap all signals

Python – Trap all signals Question: In python 2.6 under Linux, I can use the following to handle a TERM signal: import signal def handleSigTERM(): shutdown() signal.signal(signal.SIGTERM, handleSigTERM) Is there any way to setup a handler for all signals received by the process, other than just setting them up one-at-a-time? Asked By: Justin Ethier || …

Total answers: 8