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
  How to timeout a task using the ThreadpoolExecutor? lowercase00 2 8,027 Feb-07-2023, 05:44 PM
Last Post: deanhystad
  TimeOut a function in a class ? Armandito 1 3,121 Apr-25-2022, 04:51 PM
Last Post: Gribouillis
  printing contents of Jar on timeout Rakshan 1 2,730 Jul-30-2021, 07:48 AM
Last Post: buran
  socket.timeout: timed out DanielGraham 2 26,394 Dec-22-2017, 06:07 PM
Last Post: DanielGraham
  FBProphet() Timeout in Anaconda sobrio1 0 4,300 Dec-21-2017, 05:15 AM
Last Post: sobrio1
  timeout value in subprocess jonesin1974 2 11,699 Dec-01-2017, 02:18 PM
Last Post: snippsat
  pxssh timeout issue Prabakaran141 4 8,761 Aug-01-2017, 08:56 AM
Last Post: Prabakaran141
  AsyncSSH and timeout Standard_user 1 7,610 Nov-03-2016, 06:05 PM
Last Post: micseydel

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020
This forum uses Lukasz Tkacz MyBB addons.
Forum use Krzysztof "Supryk" Supryczynski addons.