How to tell when a file is closed
Emile van Sebille
emile at fenx.com
Fri Oct 5 12:51:23 EDT 2001
I automated an app this year and ended up using:
def waitForFile(fileName, waitForChange=1):
print "in waitForFile waiting on %s " % fileName
while 1:
if os.path.isfile(fileName):
break
else:
time.sleep(3)
sStats = os.stat(fileName)
time.sleep(3)
while waitForChange:
fStats = os.stat(fileName)
if fStats != sStats:
sStats = fStats
time.sleep(3)
else:
break
I certainly wouldn't depend on it in all cases, but it does what I need in
this case.
HTH,
--
Emile van Sebille
emile at fenx.com
---------
"Peter Curran" <Pcurran at intraspect.com> wrote in message
news:mailman.1002295686.29143.python-list at python.org...
> Simple problem: I have an exe that creates a new file. I call this exe
> from python with execfile, but I don't know how to tell when the exe I
> called is finished writing its file. Without using any of the extra Win32
> modules, how can I tell when the exe is finished? Would os.path.isfile
> work? Are there other utilities? If it helps, I'm actually doing this
from
> jpython -- maybe there's a java class that does this nicely? Any ideas
out
> there?
>
> Thank You!
>
> -Peter
>
>
More information about the Python-list
mailing list