我们从Python开源项目中,提取了以下4个代码示例,用于说明如何使用os.fdatasync()。
def __exit__(self, exc_type, exc_val, exc_tb): if exc_type is None: self.outfd.flush() if self.sync: os.fdatasync(self.fd) os.fchmod(self.fd, self.osmode) os.rename(self.abspath, self.fname) else: os.unlink(self.abspath) self.outfd.close() return False
def fsync(self, isfsyncfile): self._fflush() if isfsyncfile and hasattr(os, 'fdatasync'): os.fdatasync(self.fd) else: os.fsync(self.fd)
def fsync(self, path, datasync, fh): if not common.windows: if datasync != 0: os.fdatasync(fh) else: os.fsync(fh)
def uidNumber_savenext(self, fd, uidNumber): """Save next uidNumber. Writes uidNumber to file descriptor fd, which must be the one returned by uidNumber_getnext(). Does not write anything if in test mode.""" if not self.opt.test: os.lseek(fd, 0, 0) os.write(fd, '%s\n' % uidNumber) os.fdatasync(fd)