[Python-Dev] Import redesign [LONG]

Jean-Claude Wippler jcw@equi4.com
Sat, 20 Nov 1999 01:21:43 +0100


Skip Montanaro wrote:
>
[dir stat cache times]
> I took a couple minutes to write a simple script to check things.  It
> created a file, changed its mode, then unlinked it.  I was a bit
> surprised that deleting a file didn't appear to change the directory's
> mod time.  Then I realized that since file times are only recorded
> with one-second

Or two, on Windows with older (FAT, as opposed to VFAT) file systems.

> precision, you might see no change to the directory's mtime in some
> circumstances.  Adding a sleep to the script between directory
> operations resolved the apparent inconsistency.  Still, as Gordon
> stated, you probably can't count on directory modtimes to tell you
> when to invalidate the cache. It's consistent, just not reliable...
> 
> if-we-slow-import-down-enough-we-can-use-this-trick-though-ly y'rs,

If the dir stat time is less than 2 seconds ago, flush - always.

If the dir stat time says it hasn't been changed for at least 2 seconds
then you can cache all entries and trust that any change is detected.
In other words: take the *current* time into account, then it can work.

I think.  Maybe.  Until you get into network drives and clock skew...

-- Jean-Claude