Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #80009
| Path | csiph.com!usenet.pasdenom.info!gegeweb.org!usenet-fr.net!nerim.net!novso.com!newsfeed.xs4all.nl!newsfeed4a.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail |
|---|---|
| Return-Path | <rosuav@gmail.com> |
| X-Original-To | python-list@python.org |
| Delivered-To | python-list@mail.python.org |
| X-Spam-Status | OK 0.007 |
| X-Spam-Evidence | '*H*': 0.99; '*S*': 0.00; 'repository': 0.05; 'automate': 0.07; 'detect': 0.07; 'postgresql': 0.07; 'rename': 0.07; 'subject:file': 0.07; 'tries': 0.07; 'git': 0.09; 'level:': 0.09; 'subject:How': 0.10; 'cc:addr:python-list': 0.11; 'between.': 0.16; 'from:addr:rosuav': 0.16; 'from:name:chris angelico': 0.16; 'headaches': 0.16; 'personally,': 0.16; 'wrote:': 0.18; 'code.': 0.18; 'commit': 0.19; 'replacing': 0.19; 'server,': 0.19; 'written,': 0.19; 'cc:addr:python.org': 0.22; '31,': 0.24; 'looks': 0.24; 'question': 0.24; 'cc:2**0': 0.24; 'push': 0.26; 'header:In-Reply-To:1': 0.27; '[1]': 0.29; 'points': 0.29; 'thus': 0.29; "doesn't": 0.30; 'database,': 0.30; 'message- id:@mail.gmail.com': 0.30; 'file': 0.32; 'cases': 0.33; 'fri,': 0.33; 'maybe': 0.34; 'subject:the': 0.34; "i'd": 0.34; 'could': 0.34; 'something': 0.35; 'received:google.com': 0.35; 'done': 0.36; 'subject:?': 0.36; 'level': 0.37; 'remote': 0.38; 'handle': 0.38; 'pm,': 0.38; 'rather': 0.38; 'does': 0.39; 'either': 0.39; 'how': 0.40; 'failures': 0.60; 'worry': 0.60; 'lower': 0.61; 'new': 0.61; 'back': 0.62; 'such': 0.63; 'temporary': 0.65; 'saving': 0.69; 'overcome': 0.74; 'power': 0.76; 'as:': 0.81; 'it"': 0.84; 'preventing': 0.84; 'reliability': 0.84; 'opens': 0.91; 'to:none': 0.92 |
| DKIM-Signature | v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:cc :content-type; bh=VdNYuHSo2/+puyoid1O2nre8hz29vq5Vt17fojUgwK0=; b=ihlPoLDoJZ8+9K51kVlLivYv0+unqaWdoJY7xDOOirG/PA/+GsAKKZn3Wjx/+YW34q JYbqed+kU9dDDapqA2e6LZ7mhG2zRemwu0hHZhgfTnofPavG51TlNsAqx7hni3BuFcG5 jVb55UUKjYEo8aHWqwjYPmE/Z6iAkOVCeSlPB+h9cD8Sf7NPb1hybSgwYenjsGR+vhaX 6cG1z+UbgVAyioCVKcKCnHF6N41tPOf0Jpr+2ohxU77HEfUjlOtmoL/L4MyUawYS4Oya i4fxQDInbE/91cifBF2w4M1Z9mZqWBAxAUW0HjkCO3KUoeyFuQ89ER+1s6i9wbkQWAVq eUXw== |
| MIME-Version | 1.0 |
| X-Received | by 10.42.37.138 with SMTP id y10mr23330662icd.26.1414757965285; Fri, 31 Oct 2014 05:19:25 -0700 (PDT) |
| In-Reply-To | <87h9ykphm9.fsf@gmail.com> |
| References | <5452ADFD.5030801@it.uu.se> <87h9ykphm9.fsf@gmail.com> |
| Date | Fri, 31 Oct 2014 23:19:25 +1100 |
| Subject | Re: Saving a file "in the background" -- How? |
| From | Chris Angelico <rosuav@gmail.com> |
| Cc | "python-list@python.org" <python-list@python.org> |
| Content-Type | text/plain; charset=UTF-8 |
| X-BeenThere | python-list@python.org |
| X-Mailman-Version | 2.1.15 |
| Precedence | list |
| List-Id | General discussion list for the Python programming language <python-list.python.org> |
| List-Unsubscribe | <https://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 | <https://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe> |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.15352.1414757973.18130.python-list@python.org> (permalink) |
| Lines | 25 |
| NNTP-Posting-Host | 2001:888:2000:d::a6 |
| X-Trace | 1414757973 news.xs4all.nl 2941 [2001:888:2000:d::a6]:52194 |
| X-Complaints-To | abuse@xs4all.nl |
| Xref | csiph.com comp.lang.python:80009 |
Show key headers only | View raw
On Fri, Oct 31, 2014 at 11:07 PM, Akira Li <4kir4.1i@gmail.com> wrote:
> where atomic_open() [1] tries to overcome multiple issues with saving
> data reliably:
>
> - write to a temporary file so that the old data is always available
> - rename the file when all new data is written, handle cases such as:
> * "antivirus opens old file thus preventing me from replacing it"
>
> either the operation succeeds and 'backup' contains new data or it fails
> and 'backup' contains untouched ready-to-restore old data -- nothing in
> between.
Sounds like a lot of hassle, and a lot of things that could be done
wrongly. Personally, if I need that level of reliability and
atomicity, I'd rather push the whole question down to a lower level:
maybe commit something to a git repository and push it to a remote
server, or use a PostgreSQL database, or something of that sort. Let
someone else have the headaches about "what if AV opens the file". Let
someone else worry about how to cope with power failures at arbitrary
points in the code. (Though, to be fair, using git for this doesn't
fully automate failure handling; what it does is allow you to detect
issues on startup, and either roll back ("git checkout -f") or apply
("git commit -a") if it looks okay.)
ChrisA
Back to comp.lang.python | Previous | Next — Next in thread | Find similar | Unroll thread
Re: Saving a file "in the background" -- How? Chris Angelico <rosuav@gmail.com> - 2014-10-31 23:19 +1100
Re: Saving a file "in the background" -- How? Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2014-11-01 01:06 +1100
Re: Saving a file "in the background" -- How? Chris Angelico <rosuav@gmail.com> - 2014-11-01 01:29 +1100
csiph-web