#1
  1. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    May 2001
    Posts
    266
    Rep Power
    13

    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.

    Code:
    if os.path.isdir("/nfs/qa/log/build_logs/bighorn") > 0:
            print "is a dir"
    else:
            print "not a dir"
    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.
    Last edited by Theeggman; June 28th, 2004 at 12:58 PM.
  2. #2
  3. Hello World :)
    Devshed Frequenter (2500 - 2999 posts)

    Join Date
    Mar 2003
    Location
    Hull, UK
    Posts
    2,537
    Rep Power
    69
    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

    Mark.
    programming language development: www.netytan.com Hula

  4. #3
  5. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    May 2001
    Posts
    266
    Rep Power
    13
    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.
  6. #4
  7. Hello World :)
    Devshed Frequenter (2500 - 2999 posts)

    Join Date
    Mar 2003
    Location
    Hull, UK
    Posts
    2,537
    Rep Power
    69
    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:

    http://sourceforge.net/tracker/?grou...70&atid=105470

    Good luck,

    Mark.
    programming language development: www.netytan.com Hula

  8. #5
  9. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    May 2001
    Posts
    266
    Rep Power
    13
    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!
  10. #6
  11. Hello World :)
    Devshed Frequenter (2500 - 2999 posts)

    Join Date
    Mar 2003
    Location
    Hull, UK
    Posts
    2,537
    Rep Power
    69
    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.

    Take care,

    Mark.
    programming language development: www.netytan.com Hula


IMN logo majestic logo threadwatch logo seochat tools logo