Need a way to determine if a file is done being written to.

Posted by Khorkrak on Stack Overflow See other posts from Stack Overflow or by Khorkrak
Published on 2010-06-18T13:59:18Z Indexed on 2010/06/18 14:03 UTC
Read the original article Hit count: 291

Filed under:
|
|
|
|

The situation I'm in is this - there's a process that's writing to a file, sometimes the file is rather large say 400 - 500MB. I need to know when it's done writing. How can I determine this? If I look in the directory I'll see it there but it might not be done being written. Plus this needs to be done remotely - as in on the same internal LAN but not on the same computer and typically the process that wants to know when the file writing is done is running on a Linux box with a the process that's writing the file and the file itself on a windows box. No samba isn't an option. xmlrpc communication to a service on that windows box is an option as well as using snmp to check if that's viable.

Ideally

Works on either Linux or Windows - meaning the solution is OS independent. 
Works for any type of file.

Good enough:

Works just on windows but can be done through some library or whatever that can be accessed with Python.
Works only for PDF files.

Current best idea is to periodically open the file in question from some process on the windows box and look at the last bytes checking for the PDF end tag and accounting for the eol differences because the file may have been created on Linux or Windows.

© Stack Overflow or respective owner

Related posts about python

Related posts about Windows