When monitoring a FTP server with ftplib for new files, is there a way to see if a new file is still being transferred?
<p>I'm planning on using ftplib to monitor a server for new files.  Is there a way to see if a new file is still being transferred? </p>

<p>Here is a partial solution that finds new files:</p>

<p><a href="https://stackoverflow.com/questions/12118011/monitor-remote-ftp-directory">Monitor remote FTP directory</a> </p>

<pre><code>from ftplib import FTP
from time import sleep

ftp = FTP('localhost')
ftp.login()

def changemon(dir='./'):
    ls_prev = set()

    while True:
        ls = set(ftp.nlst(dir))

        add, rem = ls-ls_prev, ls_prev-ls
        if add or rem: yield add, rem

        ls_prev = ls
        sleep(5)

for add, rem in changemon():
    print('\n'.join('+ %s' % i for i in add))
    print('\n'.join('- %s' % i for i in remove))

ftp.quit()
</code></pre>