Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #25210
| Date | 2012-07-12 14:30 +0200 |
|---|---|
| From | Laszlo Nagy <gandalf@shopzeus.com> |
| Subject | Re: How to safely maintain a status file |
| References | <CAOV1wRVtm27yWez1HZuN8=ia-TyM2aXp9QCUbSZ5aZExP_ZChA@mail.gmail.com> <sanjv7lo0vb3rlhip4ov1gpgp4gs51bvfr@invalid.netcom.com> <4FF9F454.40207@shopzeus.com> <jtcvf8$ock$1@dough.gmane.org> |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.2034.1342096256.4697.python-list@python.org> (permalink) |
> You are contradicting yourself. Either the OS is providing a fully > atomic rename or it doesn't. All POSIX compatible OS provide an atomic > rename functionality that renames the file atomically or fails without > loosing the target side. On POSIX OS it doesn't matter if the target exists. This is not a contradiction. Although the rename operation is atomic, the whole "change status" process is not. It is because there are two operations: #1 delete old status file and #2. rename the new status file. And because there are two operations, there is still a race condition. I see no contradiction here. > > You don't need locks or any other fancy stuff. You just need to make > sure that you flush the data and metadata correctly to the disk and > force a re-write of the directory inode, too. It's a standard pattern on > POSIX platforms and well documented in e.g. the maildir RFC. It is not entirely true. We are talking about two processes. One is reading a file, another one is writting it. They can run at the same time, so flushing disk cache forcedly won't help.
Back to comp.lang.python | Previous | Next — Next in thread | Find similar | Unroll thread
Re: How to safely maintain a status file Laszlo Nagy <gandalf@shopzeus.com> - 2012-07-12 14:30 +0200
Re: How to safely maintain a status file Hans Mulder <hansmu@xs4all.nl> - 2012-07-12 15:19 +0200
Re: How to safely maintain a status file Laszlo Nagy <gandalf@shopzeus.com> - 2012-07-12 19:43 +0200
Re: How to safely maintain a status file Christian Heimes <lists@cheimes.de> - 2012-07-12 20:39 +0200
Re: How to safely maintain a status file Rick Johnson <rantingrickjohnson@gmail.com> - 2012-07-12 18:20 -0700
Re: How to safely maintain a status file Chris Angelico <rosuav@gmail.com> - 2012-07-13 12:12 +1000
Re: How to safely maintain a status file Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2012-07-13 03:13 +0000
Re: How to safely maintain a status file Gene Heskett <gheskett@wdtv.com> - 2012-07-12 23:49 -0400
Re: How to safely maintain a status file Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2012-07-13 04:21 +0000
Re: How to safely maintain a status file rantingrickjohnson@gmail.com - 2012-07-12 21:26 -0700
Re: How to safely maintain a status file Chris Angelico <rosuav@gmail.com> - 2012-07-13 16:02 +1000
Re: How to safely maintain a status file Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2012-07-13 07:14 +0000
Re: How to safely maintain a status file Dennis Lee Bieber <wlfraed@ix.netcom.com> - 2012-07-13 13:29 -0400
RE: How to safely maintain a status file "Prasad, Ramit" <ramit.prasad@jpmorgan.com> - 2012-07-13 16:00 +0000
Re: [Python] RE: How to safely maintain a status file Chris Gonnerman <chris@gonnerman.org> - 2012-07-13 12:27 -0500
RE: [Python] RE: How to safely maintain a status file "Prasad, Ramit" <ramit.prasad@jpmorgan.com> - 2012-07-13 17:59 +0000
Re: [Python] RE: How to safely maintain a status file Hans Mulder <hansmu@xs4all.nl> - 2012-07-13 20:28 +0200
Re: [Python] RE: How to safely maintain a status file MRAB <python@mrabarnett.plus.com> - 2012-07-13 20:57 +0100
Re: [Python] RE: How to safely maintain a status file Christian Heimes <lists@cheimes.de> - 2012-07-13 22:21 +0200
Re: [Python] RE: How to safely maintain a status file Chris Angelico <rosuav@gmail.com> - 2012-07-14 04:19 +1000
RE: How to safely maintain a status file Chris Gonnerman <chris@gonnerman.org> - 2012-07-13 15:15 -0500
Re: How to safely maintain a status file Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2012-07-14 01:53 +0000
csiph-web