Skip to content

use a temp dir to do an atomic write for the raw file output - #520

Merged
jchiang87 merged 1 commit into
mainfrom
u/jchiang/raw_file_atomic_write
Aug 28, 2026
Merged

jchiang87 merged 1 commit into
mainfrom
u/jchiang/raw_file_atomic_write

Conversation

@jchiang87

@jchiang87 jchiang87 commented Aug 28, 2026 •

Copy link
Copy Markdown
Collaborator

This addresses #517

@cwwalter cwwalter left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM..

One thing I don't quite understand: If it is messing up writing to the networked file, why does doing the os.replace always work? It is because everything is already flushed in this case and it happens in just one operation?

I mean I see in the documentation this is what you are supposed to do, but what causes the problem with the normal writeto()

@jchiang87

Copy link
Copy Markdown
Collaborator Author

The problem with .writeto is that it takes a relatively long time to do the write, so if we're running in batch and jobs time out during that operation, those files can be left incomplete. So as you note, os.replace just renames the file after everything has been written to disk.

@jchiang87
jchiang87 merged commit 91e74e8 into main Aug 28, 2026
3 checks passed
@jchiang87
jchiang87 deleted the u/jchiang/raw_file_atomic_write branch August 28, 2026 22:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants