Russell Warren
2006-07-27 21:43:37 UTC
Does it actually tell you the target is the problem? I see an
"OSError: [Errno 17] File exists" for that case, not a permission error.
A permission error could occur, for example, if GDS has the source open
or locked when you call os.rename.
No it doesn't tell me the target is the issue... you are of course"OSError: [Errno 17] File exists" for that case, not a permission error.
A permission error could occur, for example, if GDS has the source open
or locked when you call os.rename.
right that it could be either. I did some looking to see if/why GDS
would lock files at any time while scanning but didn't turn up anything
useful so far. I'd be surprised if it did as that would be one heck of
an annoying design flaw.
Anyway - the retry-on-failure workaround seems to prevent it from
happening, although it still seems very hackish and I don't like it:
...
if os.path.exists(path1): os.remove(path1)
startTime = time.clock()
while 1:
try:
os.rename(self.path2, self.path1)
break
except OSError:
if (time.clock() - startTime) > MAX_RETRY_DURATION_s:
raise
else:
time.sleep(0)
...
It feels very weird to have to verify a simple operation like this, but
if it works it works.
Russ