[Python-Dev] small PATCH to fix os.fsync on OS X (original) (raw)

Ian Charnas ian.charnas at gmail.com
Thu Aug 7 06:36:54 CEST 2008


Hello heroes and heroins of the python universe, lend me your ears and I will tell you a tale that will make your platters spin!

As noted by SQLite [1] and MySQL [2] developers, fsync on OS X does not actually flush a file to disk... instead OS X provides "fullfsync" which actually flushes the file descriptor to disk. This simple patch modifies python's "fsync" to take advantage of fullfsync on platforms that support it: http://bugs.python.org/issue3512

While some people might suggest that fullfsync should be exposed as a method on the 'os' module for platforms that support it, I believe this is not the best approach. Because the docstring for os.fsync says that it forces the file to be written to disk, I think it's up to python to ensure that functionality is really there on all platforms. Currently on OS X, fullfsync is needed to provide this functionality, so I think python's os.fsync should use fullfsync on OS X.

Looking at 'svn blame' output for Modules/posixmodule.c, I see that guido wrote the original python fsync, ronald.oussoren added all the OS X specific stuff to posixmodule.c, and recent commits have been made to that file by martin.v.loewis. christian.heimes, facundo.batista, and gregory.p.smith. Would any of you fine folks like to take a look at this? I believe it's a very small patch.

Many thanks, -Ian Charnas

[1] SQLite uses fullfsync on all platforms that define it: http://www.sqlite.org/cvstrac/fileview?f=sqlite/src/os_unix.c

[2] MySQL uses fullfsync only on the darwin platform and only when F_FULLFSYNC is defined as 51, which seems to be short-sighted in that this symbol may change value in future versions of OS X. To see this code, download a mysql 5.x source snapshot and open up mysql-/innobase/os/os0file.c



More information about the Python-Dev mailing list