Deutsch English Français Italiano |
<mailman.14.1720391247.2981.python-list@python.org> View for Bookmarking (what is this?) Look up another Usenet article |
Path: ...!weretis.net!feeder8.news.weretis.net!fu-berlin.de!uni-berlin.de!not-for-mail From: Barry <barry@barrys-emacs.org> Newsgroups: comp.lang.python Subject: Re: Best (simplest) way to share data between processes Date: Sun, 7 Jul 2024 23:27:01 +0100 Lines: 21 Message-ID: <mailman.14.1720391247.2981.python-list@python.org> References: <9a8nlk-jb81.ln1@q957.zbmc.eu> <B4D7CB24-28E5-4CAC-AA42-5C47C3F6F470@barrys-emacs.org> Mime-Version: 1.0 (1.0) Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: quoted-printable X-Trace: news.uni-berlin.de 5QhEIUr5IcgBYpLarHrsNgEFJJWhgSQdgeF10xfT9xgQ== Cancel-Lock: sha1:dfX5Reu9fgnzEHLEoPi6soYE36M= sha256:JpLruSNcVZedUqvn89WhURDw6IFpVcangx1SrzXDuUA= Return-Path: <barry@barrys-emacs.org> X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org Authentication-Results: mail.python.org; dkim=none reason="no signature"; dkim-adsp=none (unprotected policy); dkim-atps=neutral X-Spam-Status: OK 0.009 X-Spam-Evidence: '*H*': 0.98; '*S*': 0.00; 'jul': 0.04; 'cc:addr :python-list': 0.09; 'from:addr:barry': 0.09; 'received:217.70': 0.09; 'received:217.70.178': 0.09; 'received:gandi.net': 0.09; 'received:mail.gandi.net': 0.09; 'subject:between': 0.09; 'cc:no real name:2**0': 0.14; 'barry': 0.16; 'both.': 0.16; 'from:addr :barrys-emacs.org': 0.16; 'message-id:@barrys-emacs.org': 0.16; 'subject:way': 0.16; 'wrote:': 0.16; 'values': 0.17; 'cc:addr:python.org': 0.20; 'cc:2**0': 0.25; 'pattern': 0.26; 'old': 0.27; 'chris': 0.28; 'python-list': 0.32; 'there': 0.33; 'header:In-Reply-To:1': 0.34; 'close': 0.35; 'file': 0.38; 'use': 0.39; 'skip:o 10': 0.61; 'lock': 0.64; 'guaranteed': 0.67; 'prevent': 0.67; 'received:217': 0.67; 'mix': 0.69; 'contents,': 0.84; 'simultaneous': 0.84; 'tmp': 0.84; 'green': 0.96 In-Reply-To: <9a8nlk-jb81.ln1@q957.zbmc.eu> X-Mailer: iPad Mail (21F90) X-GND-Sasl: barry@barrys-emacs.org X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.39 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: <https://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> X-Mailman-Original-Message-ID: <B4D7CB24-28E5-4CAC-AA42-5C47C3F6F470@barrys-emacs.org> X-Mailman-Original-References: <9a8nlk-jb81.ln1@q957.zbmc.eu> Bytes: 3329 > On 7 Jul 2024, at 22:13, Chris Green via Python-list <python-list@python.o= rg> wrote: >=20 > a simple file lock can then > be used to prevent simultaneous access (well, simultaneous access when > the writing process is writing). There is a simple pattern to make this robust. Write new values to a tmp file. Close the tmp file. Then use os.rename(tmpfile, productionfile). This is guaranteed that any process that reads the file will only see all th= e old file contents or all the new file contents, never a mix of both. Barry