Python watchdog windows wait till copy finishes

前端 未结 7 1053
南笙
南笙 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:28

    In your on_modified event, just wait until the file is finished being copied, via watching the filesize.

    Offering a Simpler Loop:

    historicalSize = -1
    while (historicalSize != os.path.getsize(filename)):
      historicalSize = os.path.getsize(filename)
      time.sleep(1)
    print "file copy has now finished"
    

提交回复
热议问题