Python watchdog windows wait till copy finishes

前端 未结 7 1054
南笙
南笙 2021-02-05 22:39

I am using the Python watchdog module on a Windows 2012 server to monitor new files appearing on a shared drive. When watchdog notices the new file it kicks off a database resto

7条回答
  •  失恋的感觉
    2021-02-05 23:21

    I would add a comment as this isn't an answer to your question but a different approach... but I don't have enough rep yet. You could try monitoring filesize, if it stops changing you can assume copy has finished:

    copying = True
    size2 = -1
    while copying:
        size = os.path.getsize('name of file being copied')
        if size == size2:
            break
        else:
            size2 = os.path.getsize('name of file being copied')
            time.sleep(2)
    

提交回复
热议问题