os.path.getsize() on Windows

Steven D'Aprano steve at REMOVE-THIS-cybersource.com.au
Wed Mar 19 21:47:41 EDT 2008


On Wed, 19 Mar 2008 12:34:34 +0000, Duncan Booth wrote:

> Steven D'Aprano <steve at REMOVE-THIS-cybersource.com.au> wrote:
> 
>> This whole approach
>> assumes that Windows does the sensible thing of returning a unique
> error
>> code when you try to open a file for reading that is already open for
>> writing.
>> 
>> 
> So how would you use a file to share data then?


I see I was a little unclear.

What I meant to say was that I assumed that Windows returned a specific 
error code of "file is busy" as opposed to "you don't have permission to 
access this file right now" without specifying whether this is a 
permanent permissions error or a temporary file busy error.


 
> By default Python on Windows allows you to open a file for reading
> unless you specify a sharing mode which prevents it: 

But the OP is talking about another process having opened the file for 
WRITING, not reading. It's that other process that has exclusive access, 
and the OP was trying to determine when it was safe to attempt opening 
the file according to whether or not it was still growing.



-- 
Steven



More information about the Python-list mailing list