Synchronize file contents. Everything written prior to sync() must become durable before anything written after sync().
(self)
| 191 | return self.f.tell() |
| 192 | |
| 193 | def sync(self): |
| 194 | """ |
| 195 | Synchronize file contents. Everything written prior to sync() must become durable before anything written |
| 196 | after sync(). |
| 197 | """ |
| 198 | from .. import platform |
| 199 | |
| 200 | self.f.flush() |
| 201 | platform.fdatasync(self.fd) |
| 202 | # tell the OS that it does not need to cache what we just wrote, |
| 203 | # avoids spoiling the cache for the OS and other processes. |
| 204 | safe_fadvise(self.fd, 0, 0, "DONTNEED") |
| 205 | |
| 206 | def close(self): |
| 207 | """sync() and close.""" |