Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #25286

Re: [Python] RE: How to safely maintain a status file

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!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail
Return-Path <python@mrabarnett.plus.com>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.001
X-Spam-Evidence '*H*': 1.00; '*S*': 0.00; 'subject:: [': 0.03; 'subject:Python': 0.05; 'exist,': 0.07; 'referring': 0.07; 'subject:file': 0.07; 'subject:How': 0.09; 'closed,': 0.09; 'deletes': 0.09; 'exists,': 0.09; 'expectation': 0.09; 'expected.': 0.09; 'throw': 0.09; 'useless': 0.09; 'library': 0.15; 'file,': 0.15; 'slightly': 0.15; 'from:addr:mrabarnett.plus.com': 0.16; 'from:addr:python': 0.16; 'from:name:mrab': 0.16; 'message-id:@mrabarnett.plus.com': 0.16; 'posix': 0.16; 'temp': 0.16; 'wrote:': 0.17; 'deleted.': 0.17; 'handles': 0.18; 'subject:] ': 0.19; 'file.': 0.20; 'error.': 0.21; "i'd": 0.22; 'script': 0.24; 'header:In-Reply-To:1': 0.25; 'header:User-Agent:1': 0.26; 'fit': 0.26; 'handling': 0.27; 'received:192.168.1.3': 0.29; 'probably': 0.29; 'function': 0.30; 'system,': 0.32; 'towards': 0.32; 'file': 0.32; 'to:addr:python- list': 0.33; 'exist': 0.35; 'continue': 0.35; 'there': 0.35; 'created': 0.36; 'should': 0.36; 'possible': 0.37; 'does': 0.37; 'moment': 0.37; 'data': 0.37; 'subject:: ': 0.38; 'some': 0.38; 'delete': 0.38; 'to:addr:python.org': 0.39; 'received:192': 0.39; 'received:192.168': 0.40; 'your': 0.60; "you've": 0.61; 'first': 0.61; 'truly': 0.62; 'close': 0.63; 'header:Reply-To:1': 0.68; 'fact,': 0.69; 'reply-to:no real name:2**0': 0.72; 'saving': 0.72; 'lean': 0.84; 'ram,': 0.84; 'reply-to:addr:python.org': 0.84; 'say:': 0.84; 'subject:status': 0.84
X-CM-Score 0.00
X-CNFS-Analysis v=2.0 cv=O927TWBW c=1 sm=1 a=0nF1XD0wxitMEM03M9B4ZQ==:17 a=YsUzL_8ObRgA:10 a=3rAU7E97GKsA:10 a=ihvODaAuJD4A:10 a=OUOv7kDek9cA:10 a=8nJEP1OIZ-IA:10 a=EBOSESyhAAAA:8 a=8AHkEIZyAAAA:8 a=eJQkPM3EOOoiBVxGkM4A:9 a=wPNLvfGTeEIA:10 a=0nF1XD0wxitMEM03M9B4ZQ==:117
X-AUTH mrabarnett:2500
Date Fri, 13 Jul 2012 20:57:34 +0100
From MRAB <python@mrabarnett.plus.com>
User-Agent Mozilla/5.0 (Windows NT 5.1; rv:13.0) Gecko/20120614 Thunderbird/13.0.1
MIME-Version 1.0
To python-list@python.org
Subject Re: [Python] 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> <mailman.2034.1342096256.4697.python-list@python.org> <4ffecef4$0$6877$e4fe514c@news2.news.xs4all.nl> <4FFF0CB7.3030007@shopzeus.com> <mailman.2059.1342118365.4697.python-list@python.org> <fd846619-7de7-4c3b-8ed6-a14e9d55956e@p6g2000yqg.googlegroups.com> <mailman.2061.1342145524.4697.python-list@python.org> <4fff926b$0$29965$c3e8da3$5496439d@news.astraweb.com> <62e90523-a160-4e28-8109-9ce32d8952e1@googlegroups.com> <5B80DD153D7D744689F57F4FB69AF474165560E7@SCACMX008.exchad.jpmchase.net> <50005A96.3010305@gonnerman.org> <mailman.2094.1342202431.4697.python-list@python.org> <500068bd$0$6893$e4fe514c@news2.news.xs4all.nl>
In-Reply-To <500068bd$0$6893$e4fe514c@news2.news.xs4all.nl>
Content-Type text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding 7bit
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.12
Precedence list
Reply-To python-list@python.org
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.2099.1342209459.4697.python-list@python.org> (permalink)
Lines 29
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1342209459 news.xs4all.nl 6985 [2001:888:2000:d::a6]:54049
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:25286

Show key headers only | View raw


On 13/07/2012 19:28, Hans Mulder wrote:
> On 13/07/12 19:59:59, Prasad, Ramit wrote:
>
>> I lean slightly towards the POSIX handling with the addition that
>> any additional write should throw an error. You are now saving to
>> a file that will not exist the moment you close it and that is
>> probably not expected.
>
Strictly speaking, the file does exist, it's just that there are no
names referring to it. When any handles to it are also closed, the file
_can_ truly be deleted.

As has been said before, in the *nix world, "unlink" _doesn't_ delete
a file, it deletes a name.

> I'd say: it depends.
>
> If the amount of data your script needs to process does not fit
> in RAM, then you may want to write some of it to a temporary file.
> On a Posix system, it's entirely normal to unlink() a temp file
> first thing after you've created it.  The expectation is that the
> file will continue to exists, and be writeable, until you close it.
>
> In fact, there's a function in the standard library named
> tempfile.TemporaryFile that does exactly that: create a file
> and unlink it immediately.  This function would be useless
> if you couldn't write to your temporary file.
>
It's possible to create a temporary file even in Windows.

Back to comp.lang.python | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


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