Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #25055
| Path | csiph.com!usenet.pasdenom.info!gegeweb.org!de-l.enfer-du-nord.net!feeder1.enfer-du-nord.net!feeds.phibee-telecom.net!newsfeed.xs4all.nl!newsfeed5.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail |
|---|---|
| Return-Path | <python-python-list@m.gmane.org> |
| X-Original-To | python-list@python.org |
| Delivered-To | python-list@mail.python.org |
| X-Spam-Status | OK 0.000 |
| X-Spam-Evidence | '*H*': 1.00; '*S*': 0.00; 'rename': 0.07; 'subject:file': 0.07; 'terminated': 0.07; 'subject:How': 0.09; '(although': 0.09; 'flush': 0.09; 'overwrite': 0.09; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; 'atomically': 0.16; 'deleted,': 0.16; 'fancy': 0.16; 'from:addr:cheimes.de': 0.16; 'from:addr:lists': 0.16; 'from:name:christian heimes': 0.16; 'maildir': 0.16; 'message-id:@dough.gmane.org': 0.16; 'posix': 0.16; 'received:80.91.229.3': 0.16; 'received:plane.gmane.org': 0.16; 'renames': 0.16; 'side.': 0.16; 'stuff.': 0.16; 'temp': 0.16; 'documented': 0.17; 'platforms': 0.18; 'windows': 0.19; 'file.': 0.20; 'exists.': 0.22; 'work,': 0.22; '(you': 0.23; 'header:In-Reply-To:1': 0.25; 'header:User-Agent:1': 0.26; 'disk': 0.27; "doesn't": 0.28; 'header:X-Complaints-To:1': 0.28; 'locks': 0.29; 'case,': 0.29; 'e.g.': 0.30; 'compatible': 0.30; 'file': 0.32; 'could': 0.32; 'to:addr:python-list': 0.33; "can't": 0.34; 'christian': 0.34; 'too.': 0.35; 'something': 0.35; 'there': 0.35; 'received:org': 0.36; 'but': 0.36; 'correctly': 0.37; 'two': 0.37; 'data': 0.37; 'subject:: ': 0.38; 'some': 0.38; 'sure': 0.38; 'to:addr:python.org': 0.39; 'header:Received:5': 0.40; 'your': 0.60; 'matter': 0.61; 'side': 0.61; 'provide': 0.62; 'race': 0.71; 'integrity': 0.75; 'guaranteed': 0.76; 'subject:status': 0.84; 'reasons:': 0.91 |
| X-Injected-Via-Gmane | http://gmane.org/ |
| To | python-list@python.org |
| From | Christian Heimes <lists@cheimes.de> |
| Subject | Re: How to safely maintain a status file |
| Date | Sun, 08 Jul 2012 23:52:40 +0200 |
| References | <CAOV1wRVtm27yWez1HZuN8=ia-TyM2aXp9QCUbSZ5aZExP_ZChA@mail.gmail.com> <sanjv7lo0vb3rlhip4ov1gpgp4gs51bvfr@invalid.netcom.com> <4FF9F454.40207@shopzeus.com> |
| Mime-Version | 1.0 |
| Content-Type | text/plain; charset=ISO-8859-1 |
| Content-Transfer-Encoding | 7bit |
| X-Gmane-NNTP-Posting-Host | f048046007.adsl.alicedsl.de |
| User-Agent | Mozilla/5.0 (X11; Linux x86_64; rv:12.0) Gecko/20120430 Thunderbird/12.0.1 |
| In-Reply-To | <4FF9F454.40207@shopzeus.com> |
| X-BeenThere | python-list@python.org |
| X-Mailman-Version | 2.1.12 |
| Precedence | list |
| List-Id | General discussion list for the Python programming language <python-list.python.org> |
| List-Unsubscribe | <http://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe> |
| List-Archive | <http://mail.python.org/pipermail/python-list> |
| List-Post | <mailto:python-list@python.org> |
| List-Help | <mailto:python-list-request@python.org?subject=help> |
| List-Subscribe | <http://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe> |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.1929.1341784379.4697.python-list@python.org> (permalink) |
| Lines | 28 |
| NNTP-Posting-Host | 2001:888:2000:d::a6 |
| X-Trace | 1341784379 news.xs4all.nl 6988 [2001:888:2000:d::a6]:47043 |
| X-Complaints-To | abuse@xs4all.nl |
| Xref | csiph.com comp.lang.python:25055 |
Show key headers only | View raw
Am 08.07.2012 22:57, schrieb Laszlo Nagy: > But even if the rename operation is atomic, there is still a race > condition. Your program can be terminated after the original status file > has been deleted, and before the temp file was renamed. In this case, > you will be missing the status file (although your program already did > something just it could not write out the new status). 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. 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. You can use the same pattern on Windows but it doesn't work as good and doesn't guaranteed file integrity for two reasons: 1) Windows's rename isn't atomic if the right side exists. 2) Windows locks file when a program opens a file. Other programs can't rename or overwrite the file. (You can get around the issue with some extra work, though.) Christian
Back to comp.lang.python | Previous | Next — Next in thread | Find similar | Unroll thread
Re: How to safely maintain a status file Christian Heimes <lists@cheimes.de> - 2012-07-08 23:52 +0200
Re: How to safely maintain a status file John Nagle <nagle@animats.com> - 2012-07-09 13:24 -0700
Re: How to safely maintain a status file Christian Heimes <lists@cheimes.de> - 2012-07-10 01:41 +0200
Re: How to safely maintain a status file alex23 <wuwei23@gmail.com> - 2012-07-09 19:04 -0700
Re: How to safely maintain a status file Laszlo Nagy <gandalf@shopzeus.com> - 2012-07-12 14:31 +0200
csiph-web