June 28th, 2004, 12:30 PM
os.path.isdir() working erratically
I am trying to determine whether the following directory is created or not. About half the time it says it is there the other half it says it is not. The directory I'm looking for is on nfs. I have a feeling that it might be an nfs issue. I have tried to produce the same results from the python command line and have not been able to.
Just a quick update when run in a while loop 1000 times I would get either all "is a dir" or all "not a dir". It would never come up with both results.
if os.path.isdir("/nfs/qa/log/build_logs/bighorn") > 0:
print "is a dir"
print "not a dir"
Last edited by Theeggman; June 28th, 2004 at 12:58 PM.
June 29th, 2004, 08:04 AM
Give os.path.exists() a try, hopefully this will work for you though i agree with the subject line: os.path.isdir() is working erratically
June 29th, 2004, 10:46 AM
os.path.exits() does not do any better. It is the same situation. If I run code looking for the directory in a loop 5000 times, for all 5000 it will say the directory exists then the next time it is run it will say the directory does not exist.
It seems like python is looking at one "snapshot" of the directory on NFS. I need python to go and take a fresh look to see if the directory is available while looping.
Seems like this is a pretty unusual problem. And one that has be baffled . There are of course hacks that may work but i only have pretty limited access to Python (remote *nix server) right now so its hard for me to test any of this. Even then it would be much better if we could figure out just why this is happening.
You should probably report this to on the Python bug board:
My manager finally came back from vacation and I explained the problem to him. Then after talking to a few other python developers we came to the realization that the web server is load balanced. Better yet one of the servers does not have access to NFS. That explains why everything was so hit or miss. My apologies to everyone for clogging the board with python problems that are not really python problems. Lesson learned!
Ah thats ok im sure noone will really mind, the point is you thought it was a Python problem when you posted the question . So it's all good.