Atomic file write operations (cross platform)

后端 未结 7 1789
礼貌的吻别
礼貌的吻别 2020-12-28 15:34

How do I build up an atomic file write operation? The file is to be written by a Java service and read by python scripts.
For the record, reads are far greater than writ

7条回答
  •  -上瘾入骨i
    2020-12-28 16:03

    At least on POSIX platforms, leave out step 3 (delete old file). In POSIX, rename within a filesystem is guaranteed to be atomic, and renaming on top of an existing file replaces it atomically.

提交回复
热议问题