python - Monitoring if a file stopped being copied with watchdog -
i'm uploading large files (multiple gb) on webdav server , see if files still being copied (preferably check if file size still increasing) or if went wrong , upload interrupted.
at moment i'm using following code based on quick start example in watchdog package:
import sys import time import logging watchdog.observers import observer watchdog.events import filesystemeventhandler class myhandler(filesystemeventhandler): def on_created(self, event): print("started") def on_modified(self, event): print("finished") if __name__ == "__main__": path = '.' event_handler = myhandler() observer = observer() observer.schedule(event_handler, path, recursive=true) observer.start() try: while true: time.sleep(1) except keyboardinterrupt: observer.stop() observer.join()
but gives me output when file created on server , when it's finished uploading. also, when interrupt upload midway not tell me file finished uploading, says created. how check if file actively being uploaded , raise error when interrupted? can done watchdog or should use polling instead?
Comments
Post a Comment