This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author logang
Recipients Michael Mol, aguiar, exarkun, logang, pitrou, yoyoyopcp
Date 2019-12-06.17:31:25
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1575653485.64.0.374385626784.issue5396@roundup.psfhosted.org>
In-reply-to
Content
Paul's solution works in 3.7 if you set the buffer size to zero when calling fdopen.

fd = os.open("my_file", os.O_DIRECT | os.O_RDWR)
f = os.fdopen(fd, "rb+", 0)
m = mmap.mmap(-1, 4096)
f.readinto(m)

This is according to a comment in _pyio.py:

# If remaining space in callers buffer is larger than
# internal buffer, read directly into callers buffer

So by simply disabling the buffer (which is what we'd want for O_DIRECT anyway) readinto() works as expected. 

However, based on this issue, I'm a little concerned this won't be fully supported by python going forward; so use with care.
History
Date User Action Args
2019-12-06 17:31:25logangsetrecipients: + logang, exarkun, pitrou, aguiar, Michael Mol, yoyoyopcp
2019-12-06 17:31:25logangsetmessageid: <1575653485.64.0.374385626784.issue5396@roundup.psfhosted.org>
2019-12-06 17:31:25loganglinkissue5396 messages
2019-12-06 17:31:25logangcreate