[New-bugs-announce] [issue17330] Check st_nlink in addition to st_mtime to invalidate FileFinder cache

Erik Bray report at bugs.python.org
Fri Mar 1 19:38:11 CET 2013


New submission from Erik Bray:

This is vaguely related to issue14067, though the patch suggested there would make this problem worse, not better.

This addresses a problem that cropped up on OSX in which some code that, for Good Reasons, generates a module in a package directory and then expects to be able to import it.  Because HFS+ does not offer sub-second resolution for mtime the generated module is not found. We didn't have this problem on Linux or Windows.

I've attached one possible solution to the issue, which uses a tuple of st_mtime and st_nlink to determine if the cache should be invalidated.  This should pick up most file creation/deletion on such file systems even if the directory's mtime hasn't changed.  This doesn't add any additional system calls so it shouldn't have any significant performance impact.

In the meantime importlib.invalidate_caches() offers a consistent workaround, but it was surprising when this issue was found to be platform dependent.

----------
components: None
hgrepos: 178
messages: 183270
nosy: erik.bray
priority: normal
severity: normal
status: open
title: Check st_nlink in addition to st_mtime to invalidate FileFinder cache
type: behavior
versions: Python 3.3

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue17330>
_______________________________________


More information about the New-bugs-announce mailing list