My below code taking time to do sftp upload using paramiko
diff=0
while diff < 5:
t1=time.time()
ftp_client.put("./py_scripts/"+py_file,sys.argv[10]+"/"+py_file)
t2=time.time()
diff = t2-t1
ftp_client.close()
But it took time as it is wait for ftp_client.put to complete that. How can I stop the upload in between if it take more than 5 sec
I have been tried a callback as well to get time but no hope
start_time = time.time()
def check_time(size, file_size):
global start_time
if (time.time() - start_time) > 20:
raise Exception
ftp_client.put("./py_scripts/"+py_file,'/home/'+username+'/'+py_file, callback=check_time)
in pdb I found below
-> ftp_client=ssh.open_sftp()
(Pdb) s
--Call--
> c:\users\raa\appdata\local\programs\python\python39\lib\site-packages\paramiko\client.py(550)open_sftp()
-> def open_sftp(self):
(Pdb) s
> c:\users\raa\appdata\local\programs\python\python39\lib\site-packages\paramiko\client.py(556)open_sftp()
-> return self._transport.open_sftp_client()
(Pdb) s
--Call--
> c:\users\raa\appdata\local\programs\python\python39\lib\site-packages\paramiko\transport.py(1087)open_sftp_client()
-> def open_sftp_client(self):
(Pdb) n
> c:\users\raa\appdata\local\programs\python\python39\lib\site-packages\paramiko\transport.py(1097)open_sftp_client()
-> return SFTPClient.from_transport(self)
(Pdb) n
It is taking time after that