Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
FTp timeout except
#1
Hello
I'm uploading a script file to a server
which casue the server to reboot ( which is what I want )
how do I make the python ignore it? and say it's OK?
If I get not reply in 20 seconds continue ?

Is this enough?
 ftp = FTP(routerIP, timeout=20)
or I need to catch some exception?

this is what I have on the code:
except Exception as e:
            print('my error')
            print(e)
and I see I get this on the print out
my error
timed out
for me it's not an error
Thanks,
Reply
#2
If you don't expect a response why are you waiting 20 seconds instead of something shorter?

You should only capture exceptions you want to handle. The FTP timeout is a socket timeout.
from ftplib import FTP
import socket

try:
    ftp = FTP("whatever", timeout=1)
    ftp.login()
except socket.timeout:  # I expect a timeout.  I want other exceptions to crash and give me a trace
    pass
print("All done")
Reply
#3
I thought that the timeout=20 is for that reason
meaning that if no reply after 20 , is good and continue

I will try what you wrote

Thanks,
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  timeout value in subprocess jonesin1974 2 5,057 Dec-01-2017, 02:18 PM
Last Post: snippsat
  AsyncSSH and timeout Standard_user 1 5,508 Nov-03-2016, 06:05 PM
Last Post: micseydel

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020