I've googled this quite a bit and can't find a way to tell if a file is currently being accessed or at least written to. Anyone dealt with this before? If one app if writing to a file another can be reading it before the first is finished writing..

Recommended Answers

All 2 Replies

You could try to test whether the file is open by using f.closed which will return False if the file is open and True if the file is closed, for example:

f = open(somefile, 'r')
f.closed

The above will return False but:

f.close()
f.closed

This will now return True

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.