Author ncoghlan
Recipients barry, eric.araujo, eric.smith, exarkun, giampaolo.rodola, loewis, martin.panter, meatballhat, milko.krachounov, ncoghlan, neologix, olemis, pitrou, tarek, vstinner
Date 2013-05-16.00:51:38
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1368665499.5.0.696273697345.issue8604@psf.upfronthosting.co.za>
In-reply-to
Content
We have one of these in Beaker (we didn't need to wait for os.replace, since Beaker only runs on Linux): http://git.beaker-project.org/cgit/beaker/tree/Common/bkr/common/helpers.py?h=develop#n90

It turns out to be beneficial to separate the three operations in order to cooperate more cleanly with other operations on the same file system (in our case, we needed to be able to write data uploaded over a network connection to the temporary file *before* acquiring an flock when we did the rename).

We also create the file adjacent to the destination, as creating it under the /tmp heirarchy and then renaming it is invalid under SELinux (since the security context ends up being incorrect).

While Beaker is GPLv2, I'd easily be able to get permission to extract this and contribute it to the PSF.

Incidentally, I'm thinking tempfile might actually be a more sensible home for this than shutil.
History
Date User Action Args
2013-05-16 00:51:39ncoghlansetrecipients: + ncoghlan, loewis, barry, exarkun, pitrou, vstinner, eric.smith, giampaolo.rodola, tarek, eric.araujo, olemis, meatballhat, milko.krachounov, neologix, martin.panter
2013-05-16 00:51:39ncoghlansetmessageid: <1368665499.5.0.696273697345.issue8604@psf.upfronthosting.co.za>
2013-05-16 00:51:39ncoghlanlinkissue8604 messages
2013-05-16 00:51:38ncoghlancreate