import signal, time

def handler(signum, frame):
    pass
signal.signal(signal.SIGALRM, handler)
signal.alarm(2)
time.sleep(10)
signal.alarm(0)
Python Paramiko timeout with long execution, need full output