On this page
posix.fsync
Prev: posix.fstatvfs | Up: posix | Next: posix.ftruncate
Rel: posix.abort, posix.access, posix.chdir, posix.chflags
Ref: docs.python.org — posix.fsync
Tags: #public #python3 #stdlib #posix
Import
import posix
from posix import fsync
Signature & Overview
posix.fsync(fd)
Force write of fd to disk.
Usage
import os, tempfile
with tempfile.TemporaryFile('w+b') as f:
f.write(b'durable')
f.flush()
os.fsync(f.fileno())
Gotchas
- Always call
f.flush()BEFOREos.fsync(f.fileno()): Otherwise Python's user-space buffer hasn't reached the OS yet.
REPL Inspect
from posix import fsync
help(fsync)
Linked from
Related notes
- tuts/python3/stdlib_module/posix/fstatvfs Linked here; links to this page; shared tags: #posix, #stdlib
- tuts/python3/stdlib_module/posix/ftruncate Linked here; links to this page; shared tags: #posix, #stdlib
- tuts/python3/stdlib_module/posix Linked here; links to this page; shared tags: #stdlib
- tuts/python3/stdlib_module/posix/abort Linked here; shared tags: #posix, #stdlib
- tuts/python3/stdlib_module/posix/access Linked here; shared tags: #posix, #stdlib
- tuts/python3/stdlib_module/posix/chdir Linked here; shared tags: #posix, #stdlib
- tuts/python3/stdlib_module/posix/chflags Linked here; shared tags: #posix, #stdlib
- tuts/python3/stdlib_module/posix/chmod shared tags: #posix, #stdlib
- tuts/python3/stdlib_module/posix/chown shared tags: #posix, #stdlib
- tuts/python3/stdlib_module/posix/chroot shared tags: #posix, #stdlib