def file_flush_and_sync(f: io.FileIO): """ Call system sync, ensure write the file’s overflow_data to disk, but it's a EXPENSIVE op """ f.flush() os.fsync(f.fileno())
def file_flush_and_sync(f: io.FileIO): # If you’re starting with a buffered Python file object f, first do f.flush(), and then do os.fsync(f.fileno()), to ensure that all internal buffers associated with f are written to disk. f.flush() os.fsync(f.fileno())