[New-bugs-announce] [issue15723] Python breaks OS' append guarantee on file writes
Poul-Henning Kamp
report at bugs.python.org
Sat Aug 18 22:19:37 CEST 2012
New submission from Poul-Henning Kamp:
When a file is opened in append mode, the operating system guarantees that all write(2) system calls atomically appended their payload to the file.
At least on FreeBSD, Python breaks this guarantee, by chopping up large writes into multiple write(2) syscalls to the OS.
Try running this program using ktrace/truss/strace or a similar system-call tracing facility:
fo = open("/tmp/_bogus", "ab", 0)
fo.write(bytearray(1024*1024))
fo.close()
Instead of one single megabyte write, I see 1024 kilobyte writes.
(BTW: Why only one kilobyte ? That is an incredible pessimisation these days...)
I leave it to the python community to decide if this should be fixed, or merely pointed out in documentation (os.write() is a workaround)
----------
components: None
messages: 168528
nosy: bsdphk
priority: normal
severity: normal
status: open
title: Python breaks OS' append guarantee on file writes
type: behavior
versions: Python 2.7
_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue15723>
_______________________________________
More information about the New-bugs-announce
mailing list