[issue38167] O_DIRECT read fails with 4K mmap buffer

Josh Rosenberg report at bugs.python.org
Fri Oct 4 22:07:41 EDT 2019


Josh Rosenberg <shadowranger+python at gmail.com> added the comment:

> I do not believe an unbuffered file uses O_DIRECT.  This is why I use os.open(fpath, os.O_DIRECT).

Problem is you follow it with:

fo = os.fdopen(fd, 'rb+')

which introduces a Python level of buffering around the kernel unbuffered file descriptor. You'd need to pass buffering=0 to make os.fdopen avoid returning a buffered file object, making it:

fo = os.fdopen(fd, 'rb+', buffering=0)

----------

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue38167>
_______________________________________


More information about the Python-bugs-list mailing list