import signal def signal_(signum): """Decorate a function to register as a handler to the signal.""" def decorator(func): signal.signal(signum, func) return func return decorator