Two writers sharing the name state.json.tmp truncate each other's file and publish 0 bytes, while mkstemp gives each writer a private name and every rename publishes a complete file.
Python

os.replace is atomic, but a shared .tmp name one step earlier still corrupts the file

Six processes writing one state file via a fixed .tmp name: 121-162 corrupt reads out of 200. tempfile.mkstemp in the same directory: zero.