Re: [Python-Dev] best place for an atomic file API

2012-02-16 Thread Serhiy Storchaka
15.02.12 23:16, Charles-François Natali написав(ла): Issue #8604 aims at adding an atomic file API to make it easier to create/update files atomically, using rename() on POSIX systems and MoveFileEx() on Windows (which are now available through os.replace()). It would also use fsync() on POSIX to

Re: [Python-Dev] best place for an atomic file API

2012-02-16 Thread Vinay Sajip
Martin v. Löwis v.loewis.de> writes: > One way of providing this might be a "u" mode for open, which > updates an existing file on close (unlike "a", which appends, > and unlike "w", which truncates first). Doesn't "r+" cover this? Regards, Vinay Sajip

Re: [Python-Dev] best place for an atomic file API

2012-02-16 Thread Martin v. Löwis
Am 16.02.2012 10:54, schrieb Victor Stinner: > Most users don't need a truly ACID write, but implement their own > best-effort function. Instead of having a different implement in each > project, Python can provide something better, especially when the OS > provides low level function to implement

Re: [Python-Dev] best place for an atomic file API

2012-02-16 Thread Victor Stinner
Most users don't need a truly ACID write, but implement their own best-effort function. Instead of having a different implement in each project, Python can provide something better, especially when the OS provides low level function to implement such feature. Victor 2012/2/16 "Martin v. Löwis" :

Re: [Python-Dev] best place for an atomic file API

2012-02-16 Thread Martin v. Löwis
> (MvL complained in the tracker issue about a lack of concrete use > cases, but I think fixing race conditions when overwriting bytecode > files in importlib and the existing distutils/packaging use cases > cover that) I certainly agree that there are applications of "atomic replace", and that th

Re: [Python-Dev] best place for an atomic file API

2012-02-15 Thread Nick Coghlan
On Thu, Feb 16, 2012 at 11:49 AM, Ben Finney wrote: > No, I have no objection to that implementation. I'm pointing that out > only because the nature of the functionality implies I'd expect to find > it within the ‘os’ module hierarchy. The (very) rough rule of thumb is that the os module handles

Re: [Python-Dev] best place for an atomic file API

2012-02-15 Thread Ben Finney
Brian Curtin writes: > On Wed, Feb 15, 2012 at 19:19, Ben Finney wrote: > > Charles-François Natali writes: > > > >> […] using rename() on POSIX systems and MoveFileEx() on Windows > >> (which are now available through os.replace()). It would also use > >> fsync() on POSIX to make sure data is

Re: [Python-Dev] best place for an atomic file API

2012-02-15 Thread Brian Curtin
On Wed, Feb 15, 2012 at 19:19, Ben Finney wrote: > Charles-François Natali writes: > >> Issue #8604 aims at adding an atomic file API to make it easier to >> create/update files atomically, using rename() on POSIX systems and >> MoveFileEx() on Windows (which are now available through >> os.repla

Re: [Python-Dev] best place for an atomic file API

2012-02-15 Thread Ben Finney
Charles-François Natali writes: > Issue #8604 aims at adding an atomic file API to make it easier to > create/update files atomically, using rename() on POSIX systems and > MoveFileEx() on Windows (which are now available through > os.replace()). It would also use fsync() on POSIX to make sure da

Re: [Python-Dev] best place for an atomic file API

2012-02-15 Thread Nick Coghlan
On Thu, Feb 16, 2012 at 9:29 AM, Steven D'Aprano wrote: > Charles-François Natali wrote: >> What would be the best place for a such a class? >> _pyio, tempfile, or a new atomicfile > > > shutil perhaps? > > As a user, that's the third place I look for file utilities, after builtin > functions and

Re: [Python-Dev] best place for an atomic file API

2012-02-15 Thread Steven D'Aprano
Charles-François Natali wrote: Hi, Issue #8604 aims at adding an atomic file API to make it easier to create/update files atomically, using rename() on POSIX systems and MoveFileEx() on Windows (which are now available through os.replace()). It would also use fsync() on POSIX to make sure data i

[Python-Dev] best place for an atomic file API

2012-02-15 Thread Charles-François Natali
Hi, Issue #8604 aims at adding an atomic file API to make it easier to create/update files atomically, using rename() on POSIX systems and MoveFileEx() on Windows (which are now available through os.replace()). It would also use fsync() on POSIX to make sure data is committed to disk. For example,