Determining when a file has finished copying

Manuel Vazquez Acosta mva.led at gmail.com
Wed Jul 9 18:09:55 CEST 2008


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

This seems a synchronization problem. A scenario description could clear
things up so we can help:

Program W (The workflow) copies file F to directory B
Program D (the dog) polls directory B to find is there's any new file F

In this scenario, program D does not know whether F has been fully
copied, but W does.

Solution:
Create a custom lock mechanism. Program W writes a file D/F.lock to
indicate file F is not complete, it's removed when F is fully copied.
I program W crashes in mid-copy both F and F.lock are kept so program D
does not bother to process F. Recovery from the crash in W would another
issue to tackle down.

Best regards,
Manuel.

writeson wrote:
> Hi all,
> 
> I'm writing some code that monitors a directory for the appearance of
> files from a workflow. When those files appear I write a command file
> to a device that tells the device how to process the file. The
> appearance of the command file triggers the device to grab the
> original file. My problem is I don't want to write the command file to
> the device until the original file from the workflow has been copied
> completely. Since these files are large, my program has a good chance
> of scanning the directory while they are mid-copy, so I need to
> determine which files are finished being copied and which are still
> mid-copy.
> 
> I haven't seen anything on Google talking about this, and I don't see
> an obvious way of doing this using the os.stat() method on the
> filepath. Anyone have any ideas about how I might accomplish this?
> 
> Thanks in advance!
> Doug
> --
> http://mail.python.org/mailman/listinfo/python-list
> 

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iEYEARECAAYFAkh04skACgkQI2zpkmcEAhi0eQCgsVqg51fWiwi47jxqtbR8Gz2U
UukAoKm15UAm3KpEyjhsIGQ+68rq8WuU
=UFHi
-----END PGP SIGNATURE-----



More information about the Python-list mailing list