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


Groups > comp.lang.python > #25051

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!cs.uu.nl!news.stack.nl!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.001
X-Spam-Evidence '*H*': 1.00; '*S*': 0.00; 'else:': 0.03; 'startup': 0.05; 'rename': 0.07; 'subject:file': 0.07; 'subject:How': 0.09; 'exist.': 0.09; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; 'violates': 0.09; 'suggest': 0.11; 'file,': 0.15; 'crashed': 0.16; 'received:80.91.229.3': 0.16; 'received:plane.gmane.org': 0.16; 'temp': 0.16; 'tmp_file': 0.16; 'file.': 0.20; "i'd": 0.22; 'seems': 0.23; 'header:X-Complaints-To:1': 0.28; 'code': 0.31; 'could': 0.32; 'url:home': 0.33; 'to:addr:python-list': 0.33; 'skip:d 20': 0.34; 'that,': 0.34; 'richard': 0.35; 'received:org': 0.36; 'but': 0.36; 'charset:us-ascii': 0.36; 'does': 0.37; 'rather': 0.37; 'subject:: ': 0.38; 'delete': 0.38; 'to:addr:python.org': 0.39; 'skip:" 10': 0.40; 'header:Received:5': 0.40; 'your': 0.60; 'jul': 0.65; 'snapshot': 0.84; 'subject:status': 0.84; 'dennis': 0.91
X-Injected-Via-Gmane http://gmane.org/
To python-list@python.org
From Dennis Lee Bieber <wlfraed@ix.netcom.com>
Subject Re: How to safely maintain a status file
Date Sun, 08 Jul 2012 15:35:30 -0400
Organization > Bestiaria Support Staff <
References <CAOV1wRVtm27yWez1HZuN8=ia-TyM2aXp9QCUbSZ5aZExP_ZChA@mail.gmail.com>
Mime-Version 1.0
Content-Type text/plain; charset=us-ascii
Content-Transfer-Encoding 7bit
X-Gmane-NNTP-Posting-Host adsl-76-253-102-122.dsl.klmzmi.sbcglobal.net
X-Newsreader Forte Agent 3.3/32.846
X-No-Archive YES
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.1925.1341776139.4697.python-list@python.org> (permalink)
Lines 40
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1341776139 news.xs4all.nl 6937 [2001:888:2000:d::a6]:56449
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:25051

Show key headers only | View raw


On Sun, 8 Jul 2012 21:29:41 +1000, Richard Baron Penman
<richardbp@gmail.com> declaimed the following in
gmane.comp.python.general:


> and then on startup read from tmp_file if status_file does not exist.
> But this seems awkward.
>
	It also violates your requirement -- since the "crash" could take
place with a partial "temp file".

	I'd suggest that, rather than deleting the old status file, you
rename IT -- and only delete it IF you successfully rename the temp
file.

#pseudo code -- initialization
if exists("old-status.file"):
	#assume system crashed
	if exists("status.file"):
		delete("status.file")
		rename("old-status.file", "status.file")
	
if exists("status.file"):
	read("status.file")
	rename("status.file", "old-status.file")
else:
	#start-up with no status history

# -- snapshot
if exists("status.file"):
	if exists("old-status.file"):
		delete("old-status.file")
	rename("status.file", "old-status.file")
write("temp.file", "snapshot-data")
rename("temp.file", "status.file")
delete("old-status.file")
-- 
	Wulfraed                 Dennis Lee Bieber         AF6VN
        wlfraed@ix.netcom.com    HTTP://wlfraed.home.netcom.com/

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


Thread

Re: How to safely maintain a status file Dennis Lee Bieber <wlfraed@ix.netcom.com> - 2012-07-08 15:35 -0400
  Re: How to safely maintain a status file Plumo <richardbp@gmail.com> - 2012-07-08 22:58 -0700

csiph-web