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 Michael Mol
Recipients Michael Mol, aguiar, exarkun, pitrou
Date 2016-09-13.19:20:19
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1473794419.48.0.0166933481667.issue5396@psf.upfronthosting.co.za>
In-reply-to
Content
I need to remember not to try to write quick programs in Python that need O_DIRECT.

My use case: I'm attempting to write a program that forces the disk to seek to a particular place, as part of burning in the disk.

My algorithm goes:

1. Seek to the beginning of the disk
2. Write to the disk
3. Seek to the end of the disk
4. Write to the disk
5. Seek to the beginning of the disk
6. Read from the disk
7. Seek to the end of the disk
8. Read from the disk

It then repeats with offsets, leading the seek distance to shrink until the two positions overlap at the center of the disk, and then expand as the positions diverge to the opposite end of the disk from where they began.

It's straightforward, and can be done using mmap and os.write as far as the writing side of things goes, but it does not work on the reading side, as even this workaround does not work:

d = os.open(disk_file_path, os.O_RDWR | os.O_DIRECT | os.O_SYNC | os.O_DSYNC)
readbuf = mmap.mmap(-1, 4096)
os.lseek(d, 0, os.SEEK_SET)
fo = os.fdopen(d, 'rb')
fo.readinto(readbuf)

... I get errno 22 on the final line. Apparently, code similar to that used to work, but no longer does.
History
Date User Action Args
2016-09-13 19:20:19Michael Molsetrecipients: + Michael Mol, exarkun, pitrou, aguiar
2016-09-13 19:20:19Michael Molsetmessageid: <1473794419.48.0.0166933481667.issue5396@psf.upfronthosting.co.za>
2016-09-13 19:20:19Michael Mollinkissue5396 messages
2016-09-13 19:20:19Michael Molcreate