Python os.fdatasync() Method
Example
Force write of file to disc:
# Import os Library
import os
# Open file
fd = os.open("file.txt", os.O_RDWR)
# Write a bytestring
str = b"test"
os.write(fd, str)
# Perform force write on file
os.fdatasync(fd)
print("Force write on file applied successfully")
# Close the file
os.close(fd)
Definition and Usage
The os.fdatasync()
forces write of a file to disc.
This method does not force update of metadata (like
os.fsync()).
Note: Available only on UNIX platforms.
Syntax
os.fdatasync(fd)
Parameter Values
Parameter | Description |
---|---|
fd | Required. A file descriptor |
Technical Details
Return Value: | None |
---|---|
Python Version: | pre-2.6 |