]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
fsync(): Implemented for Windows, via calling MS _commit. This counts
authorTim Peters <tim.peters@gmail.com>
Wed, 23 Apr 2003 20:14:12 +0000 (20:14 +0000)
committerTim Peters <tim.peters@gmail.com>
Wed, 23 Apr 2003 20:14:12 +0000 (20:14 +0000)
as "a bug" because there's no other way in core Python to ensure that
bytes written are actually on disk.  At least ZODB wants this guarantee,
for robustness against crashes.

Doc/lib/libos.tex
Misc/NEWS
Modules/posixmodule.c

index 3d0b4051bd3feb1d0b3669f6be997996aeabf5db..7a6383f2a5dda9143fbbd0329f2624ed0d9526ac 100644 (file)
@@ -433,8 +433,15 @@ Availability: \UNIX.
 \end{funcdesc}
 
 \begin{funcdesc}{fsync}{fd}
-Force write of file with filedescriptor \var{fd} to disk.
-Availability: \UNIX.
+Force write of file with filedescriptor \var{fd} to disk.  On \UNIX,
+this calls the native \cfunction{fsync()} function; on Windows, the
+MS \cfunction{_commit()} function.
+
+If you're starting with a Python file object \var{f}, first do
+\code{\var{f}.flush()}, and then do \code{os.fsync(\var{f}.fileno()},
+to ensure that all internal buffers associated with \var{f} are written
+to disk.
+Availability: \UNIX, and Windows starting in 2.2.3.
 \end{funcdesc}
 
 \begin{funcdesc}{ftruncate}{fd, length}
index b22a277c95052d4f743234d5455c93dc5a6494e5..ed690b5cb0fd723ee0bdcc2545396399e6e4343f 100644 (file)
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -2,6 +2,10 @@ What's New in Python 2.2.3 ?
 Release date: XX-XXX-2003
 ============================
 
+- Implemented os.fsync() for Windows, where it calls the MS _commit()
+  function.  Before, there was no way in core Python to ensure file
+  writes actually showed up on disk when necessary.
+
 - Make all the strip, lstrip, rstrip functions/methods on
   string/unicode/UserString consistent by adding and/or
   documenting the chars parameter.  The chars parameter
index f41d42dc8e474fed9568ac389a62292252de4e77..a070ea6be7ec56d70c5beae04e8e4975c5f9d26d 100644 (file)
@@ -72,6 +72,8 @@ corresponding Unix manual entries for more information on calls.";
 #else
 #ifdef _MSC_VER                /* Microsoft compiler */
 #define HAVE_GETCWD     1
+#define HAVE_FSYNC     1
+#define fsync _commit
 #ifdef MS_WIN32
 #define HAVE_SPAWNV    1
 #define HAVE_EXECV      1