BIG NOTE: This is not equivalent to fsync(). It's not a
request to sync dirty data.
Flush is called on each close() of a file descriptor. So if a
filesystem wants to return write errors in close() and the file
has cached dirty data, this is a good place to write back data
and return any errors. Since many applications ignore close()
errors this is not always useful.
NOTE: The flush() method may be called more than once for each
open(). This happens if more than one file descriptor refers
to an opened file due to dup(), dup2() or fork() calls. It is
not possible to determine if a flush is final, so each flush
should be treated equally. Multiple write-flush sequences are
relatively rare, so this shouldn't be a problem.
Filesystems shouldn't assume that flush will always be called
after some writes, or that if will be called at all.
Possibly flush cached data
BIG NOTE: This is not equivalent to fsync(). It's not a request to sync dirty data.
Flush is called on each close() of a file descriptor. So if a filesystem wants to return write errors in close() and the file has cached dirty data, this is a good place to write back data and return any errors. Since many applications ignore close() errors this is not always useful.
NOTE: The flush() method may be called more than once for each open(). This happens if more than one file descriptor refers to an opened file due to dup(), dup2() or fork() calls. It is not possible to determine if a flush is final, so each flush should be treated equally. Multiple write-flush sequences are relatively rare, so this shouldn't be a problem.
Filesystems shouldn't assume that flush will always be called after some writes, or that if will be called at all.
Changed in version 2.2