import signal def timeout(signum, frame): raise IOError, "Aaaaaah! Tempo scaduto !" try: signal.signal(signal.SIGALRM, timeout) signal.alarm(3) # Tempo in secondi mssql = _mssql.connect(host,'sa','') mssql.close() signal.alarm(0) except IOError: ...