Search code examples
pythonexceptiontelnetconnection-timeouttimeoutexception

Python using try to reduce timeout wait


I am using exscripts module which has a call conn.connect('IP address'). It tries to open a telnet session to that IP. It will generate an error after connection times out. The timeout exception is set somewhere in the code of the module or it would be what the default for telnet is. (not sure)

This timeout time is too long and slowing down the script if 1 device is not reachable. Is there something we can do with the try except here ? Like

Try for 3 secs: then process the code except: print " timed out"


Solution

  • I think you can use

    conn = Telnet(timeout=3)
    

    I dont know whether timeout in seconds. If microseconds, try 3000