def _fsync_files(filenames):
 touched_directories = set()
 mode = os.O_RDONLY
 if hasattr(os, 'O_BINARY'):
  mode |= os.O_BINARY
 for filename in filenames:
  fd = os.open(filename, mode)
  os.fsync(fd)
  os.close(fd)
  touched_directories.add(os.path.dirname(filename))
 if hasattr(os, 'O_DIRECTORY'):
  for dirname in touched_directories:
   fd = os.open(dirname, (os.O_RDONLY | os.O_DIRECTORY))
   os.fsync(fd)
   os.close(fd)

def _fsync_files ( filenames ) : touched_directories = set ( ) mode = os . O_RDONLY if hasattr ( os , 'O_BINARY' ) : mode |= os . O_BINARY for filename in filenames : fd = os . open ( filename , mode ) os . fsync ( fd ) os . close ( fd ) touched_directories . add ( os . path . dirname ( filename ) ) if hasattr ( os , 'O_DIRECTORY' ) : for dirname in touched_directories : fd = os . open ( dirname , ( os . O_RDONLY | os . O_DIRECTORY ) ) os . fsync ( fd ) os . close ( fd )
call fsync() a list of file names the filenames should be absolute paths already .