I have code similar to the following running in a script:
try: s = ftplib.FTP('xxx.xxx.xxx.xxx','username','password') except: print ('Could not contact FTP serer') sys.exit()
If the FTP site is unavailable, the script almost seems to be hanging ... On average, it takes about 75 seconds before sys.exit () appears ... I know that 75 seconds is probably very subjective, and depends from the system it is running on ... but is there a way for python to just try it once, and if it was unacceptable, exit immediately? The platform I use for this is Mac OS X 10.5 / python 2.5.1.
source share