File tree Expand file tree Collapse file tree 1 file changed +14
-9
lines changed
Expand file tree Collapse file tree 1 file changed +14
-9
lines changed Original file line number Diff line number Diff line change @@ -471,16 +471,21 @@ def get_file(
471471
472472def _put_file (host : "Host" , filename_or_io , remote_location ):
473473 attempts = 1
474+ last_e = None
474475
475- try :
476- with get_file_io (filename_or_io ) as file_io :
477- sftp = _get_sftp_connection (host )
478- sftp .putfo (file_io , remote_location )
479- except OSError as e :
480- if attempts > 3 :
481- raise
482- logger .warning (f"Failed to upload file, retrying: { e } " )
483- attempts += 1
476+ while attempts < 4 :
477+ try :
478+ with get_file_io (filename_or_io ) as file_io :
479+ sftp = _get_sftp_connection (host )
480+ sftp .putfo (file_io , remote_location )
481+ return
482+ except OSError as e :
483+ logger .warning (f"Failed to upload file, retrying: { e } " )
484+ attempts += 1
485+ last_e = e
486+
487+ if last_e is not None :
488+ raise last_e
484489
485490
486491def put_file (
You can’t perform that action at this time.
0 commit comments