On Fri, Dec 25, 2020 at 9:30 AM Steven D'Aprano <st...@pearwood.info> wrote:
> Perhaps a "sync on close" keyword argument to open? At least then it is
> always available and easily discoverable.

+1 (though this is really just bikeshedding)

> > 3. There are many ways to do this, and I think several of them could
> > be subtly incorrect.
>
> Can you elaborate?
>
> I mean, the obvious way is:
>
>     try:
>         with open(..., 'w') as f:
>             f.write("stuff")
>     finally:
>         os.sync()
>
> so maybe all we really need is a "sync file" context manager.
>

Does that sync the entire file system or just that one file? If
there's a way to sync just one file, that would be potentially a LOT
more efficient.

ChrisA
_______________________________________________
Python-ideas mailing list -- python-ideas@python.org
To unsubscribe send an email to python-ideas-le...@python.org
https://mail.python.org/mailman3/lists/python-ideas.python.org/
Message archived at 
https://mail.python.org/archives/list/python-ideas@python.org/message/KG6MRQ6UULF3RO5X26ZKYRTQ3IUPJPND/
Code of Conduct: http://python.org/psf/codeofconduct/

Reply via email to