Python watchdog windows wait till copy finishes

前端 未结 7 1069
南笙
南笙 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:34

    I had a similar issue recently with watchdog. A rather simple but not very smart workaround was for me to check the change of file size in a while loop using a two-element list, one for 'past', one for 'now'. Once the the values are equal the copying is finished.

    Edit: something like this.

    past = 0
    now = 1
    value = [past, now]
    while True:
        # change
    
        # test
        if value[0] == value[1]:
            break
        else:
            value = [value[1], value[0]]
    

提交回复
热议问题