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


Groups > comp.lang.python > #50428

Re: Concurrent writes to the same file

Path csiph.com!usenet.pasdenom.info!gegeweb.org!de-l.enfer-du-nord.net!feeder1.enfer-du-nord.net!border1.nntp.ams2.giganews.com!border3.nntp.ams.giganews.com!border1.nntp.ams.giganews.com!nntp.giganews.com!feeder3.cambriumusenet.nl!feed.tweaknews.nl!81.171.88.250.MISMATCH!newsfeed.eweka.nl!eweka.nl!feeder3.eweka.nl!212.23.6.68.MISMATCH!zen.net.uk!hamilton.zen.co.uk!reader03.nrc01.news.zen.net.uk.POSTED!not-for-mail
From Nobody <nobody@nowhere.com>
Subject Re: Concurrent writes to the same file
Date Thu, 11 Jul 2013 09:30:35 +0100
User-Agent Pan/0.14.2 (This is not a psychotic episode. It's a cleansing moment of clarity.)
Message-Id <pan.2013.07.11.08.30.35.284000@nowhere.com>
Newsgroups comp.lang.python
References <mailman.4565.1373518632.3114.python-list@python.org>
MIME-Version 1.0
Content-Type text/plain; charset=UTF-8
Content-Transfer-Encoding 8bit
Lines 19
Organization Zen Internet
NNTP-Posting-Host d7eba797.news.zen.co.uk
X-Trace DXC=c9]F7jbERKX:NKnQ:_cV[Sf2FgniPJjgR=dR0\ckLKGPWeZ<[7LZNRVLIX;Wc]:EQYM2Z^cWRFGA[L\leNZRP:\P
X-Complaints-To abuse@zen.co.uk
Xref csiph.com comp.lang.python:50428

Show key headers only | View raw


On Wed, 10 Jul 2013 22:57:09 -0600, Jason Friedman wrote:

> Other than using a database, what are my options for allowing two processes
> to edit the same file at the same time?  When I say same time, I can accept
> delays.

What do you mean by "edit"? Overwriting bytes and appending bytes are
simple enough, but inserting or deleting bytes such that subsequent bytes
change their offsets is harder.

> I considered lock files,

Well, you shouldn't have, unless you're targeting a platform which doesn't
support file locks (are there any left?).

> but I cannot conceive of how I avoid race conditions.

By using locks. E.g. fcntl.lockf() or msvcrt.locking().

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


Thread

Concurrent writes to the same file Jason Friedman <jsf80238@gmail.com> - 2013-07-10 22:57 -0600
  Re: Concurrent writes to the same file Nobody <nobody@nowhere.com> - 2013-07-11 09:30 +0100

csiph-web