Detecting open files and forcing closure
arobert at townisp.com
Sat Jan 10 04:06:03 CET 2009
> Andrew Robert wrote:
>> Hi Everyone,
>> We have a process that does a copy of a share from one location to
>> This usually works fine but can occasionally bomb if a file is opened
>> by a user somewhere.
>> Is there a way to code detection of open files and force a close?
>> The files in question are typically PDF files if that matters.
>> Any pointers you can provide on this would be greatly appreciated.
> If the file is open then an exception will be raised. You could catch
> it, sleep a while, and then retry, or continue with the other files and
> then come back to it and retry. It might take more than one retry.
> Anyway, it's a bad idea to force a close, even if that's possible.
The usual scenario is that a user will leave a PDF open and then go home
for the evening. They are simply viewing and not modifying the file.
When the XCOPY executes, it signals a failure and subsequent scheduler
What I need to do is detect if files are open for viewing and force a
close before the copy operation is attempted.
Sleeping and retrying the copy is not an option because the user will
likely leave it open all night.
Is there a way to detect the open files and close them out?
More information about the Python-list