On 01May2017 14:31, Tim Chase <python.l...@tim.thechases.com> wrote:
On 2017-05-01 18:40, Gregory Ewing wrote:
The following function should be immune to race conditions
and doesn't use mktemp. [loop trying names until os.link does not fail die to an existing name]

Ah, this is a good alternative and solves the problem at hand.

As a side-note, apparently os.rename() is only atomic on *nix
systems, but not on Windows.  For the time being, I'm okay with that.

Just to your point about my (bogus) suggestion with NamedTemporaryFile, only alternative is a temporary directory, then making a file inside that. But Gregory Ewing's suggestion is much more direct.

Cheers,
Cameron Simpson <c...@zip.com.au>
--
https://mail.python.org/mailman/listinfo/python-list

Reply via email to