Re: os.path.getsize() on Windows
- From: Steven D'Aprano <steve@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx>
- Date: Thu, 20 Mar 2008 22:47:15 -0000
On Thu, 20 Mar 2008 13:42:22 +0000, Duncan Booth wrote:
Steven D'Aprano <steve@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx> wrote:
On Wed, 19 Mar 2008 12:34:34 +0000, Duncan Booth wrote:No, unless the other process has specified that it wants exclusive
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.
access there is nothing stopping his process also opening the file.
That's why he has to specify when he opens it that he wants exclusive
access: then it doesn't matter what the other process does, he won't be
able to open it until the other process has closed the file.
I think you're confused. Or possibly I'm confused. Or both.
It seems to me that you're assuming that the OP has opened the file for
reading first, and *then* another process comes along and wants to open
it for writing. That's not how I read his post: he's trying to open a
file for reading while it is already being written to by another process.
Asking for exclusive access when reading isn't going to make any
difference, because the other process has already opened the file for
writing.
I suppose it is conceivable that the other process might have opened the
file for non-exclusive writing, assuming that such a thing is even
possible, but how likely is that?
This all of course assumes that the other process writes the file in one
single atomic chunk. If it were to create it and then separately open
and write to it then all bets are off.
The OP is repeatedly polling the file to see when the size stops
increasing. Obviously a single atomic write is *not* taking place.
--
Steven
.
- Follow-Ups:
- Re: os.path.getsize() on Windows
- From: Duncan Booth
- Re: os.path.getsize() on Windows
- References:
- os.path.getsize() on Windows
- From: Sean DiZazzo
- Re: os.path.getsize() on Windows
- From: Steven D'Aprano
- Re: os.path.getsize() on Windows
- From: Duncan Booth
- Re: os.path.getsize() on Windows
- From: Steven D'Aprano
- Re: os.path.getsize() on Windows
- From: Duncan Booth
- os.path.getsize() on Windows
- Prev by Date: Re: eval and unicode
- Next by Date: Re: What is The Eric4 IDE???
- Previous by thread: Re: os.path.getsize() on Windows
- Next by thread: Re: os.path.getsize() on Windows
- Index(es):
Relevant Pages
|