[Python] Run loop while writing to paramiko SFTP file is in progress [duplicate]

Discussão em 'Python' iniciado por Stack, Fevereiro 13, 2025.

  1. Stack

    Stack Membro Participativo

    Question Is there any way to run a while loop (or something similar) that runs while a paramiko.sftp_file.SFTPFile is being written?

    Background

    I'm writing a script that will transfer large amounts of data to an SFTP server, and I'd like to have some sort of terminal print-out during the long loading time for troubleshooting/debugging. I'm using paramiko for the SFTP connection and file writing

    What I currently have it this

    remote_zip_file = sftp_client.file(file_name_with_path, "wb")

    remote_zip_file.write(my_data)


    What I'd like is something like this (pseudo code)

    remote_zip_file = sftp_client.file(file_name_with_path, "wb")

    while remote_zip_file.write(my_data) == IN_PROGRESS:
    time.sleep(1)
    print('Some print out that shows that the file writing is in progress')


    Is this possible in python, and if so, how could it be done?

    Continue reading...

Compartilhe esta Página