Whenever I open() a file with Python, the last access time is not updated, that's very odd :
If I open with r/rb nothing changes if I stat the file
If I open with w/r+ or a the ctime and mtime update properly but not atime
It doesn't look like it is a filesystem problem (which is ext3 in this case) because if I touch or cat the file it does update properly.
I haven't been able to find a lot of information about it; is it supposed to behave this way or is there something wrong?
Please try running mount, and see, if noatime flag is used on the mounted fs. Also, if your kernel is fresh enough, it's the "relatime" that is set by-default.
The "open()" code is pretty self-explanatory and does not mess with ATIME flags:
/* >> fileutils.c from Python 3.2.3 */
FILE*
_Py_fopen(PyObject *path, const char *mode)
{
#ifdef MS_WINDOWS
wchar_t wmode[10];
int usize;
usize = MultiByteToWideChar(CP_ACP, 0, mode, -1, wmode, sizeof(wmode));
if (usize == 0)
return NULL;
return _wfopen(PyUnicode_AS_UNICODE(path), wmode);
#else
FILE *f;
PyObject *bytes = PyUnicode_EncodeFSDefault(path);
if (bytes == NULL)
return NULL;
/* >> Plain fopen(), nothing fancy here. */
f = fopen(PyBytes_AS_STRING(bytes), mode);
Py_DECREF(bytes);
return f;
#endif
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With