I am working with a FTP Server where i would like to try to connect at it constantly when i have no response of it like internet failed or something. I proved under normal conditions and i am able to connect succesfully but what i want now is to loop the connection with a certain time since after some seconds of trying to connect the Jupyter notebook gives me an error and stops the program.
The objective is to be able to constantly try to connect to the ftp server until it does and then jump to the next statement While a==1: so since i had that jupyter notebook problem what i tryed is to put an if where after 5 seconds it breaks the loop.
Does someone have any other solution to this it still doesn't work.Thx for reading :)
while a==0:
print('starting 1rst loop')
while True:
timeout = time.time() + 5 # 5 seconds from now
while a==0 :
print("Connecting to FTP Server")
#domain name or server ip:
ftp = FTP('ftpIP')
#Passw and User
ftp.login(user=XXX, passwd = XXX)
print('Connected to the FTP server')
ftp.quit()
ftp.close()
a= a+1
if a==0 and time.time() > timeout:
timeout=0
break
while a==1: