On Thu, 4 Feb 2010 10:46:02 -0800 (PST) "Edward K. Ream" <[email protected]> wrote:
> The bad news is that the following code in createBackupFile can still > create a race condition: > > > fd,backupName = tempfile.mkstemp(text=False) > os.close(fd) > shutil.move(fileName,backupName) That bites. I've used that pattern without problems, but I guess it always made me nervous. fd,backupName = tempfile.mkstemp(text=False) os.write(fd, open(fileName, 'rb').read()) is... probably not good enough. Inefficient when backupName and fileName are on the same disk, and bad when fileName is big. os.fsync(fd) help at all? Can't really see how, as you can't call it after .close(). Cheers -Terry -- You received this message because you are subscribed to the Google Groups "leo-editor" group. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/leo-editor?hl=en.
