Python watchdog windows wait till copy finishes

前端 未结 7 1065
南笙
南笙 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:39

    This works for me. Tested in windows as well with python3.7

    while True:
            size_now = os.path.getsize(event.src_path)
            if size_now == size_past:
                log.debug("file has copied completely now size: %s", size_now)
                break
                # TODO: why sleep is not working here ?
            else:
                size_past = os.path.getsize(event.src_path)
                log.debug("file copying size: %s", size_past)
    
    0 讨论(0)
提交回复
热议问题