Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #196400
| Path | csiph.com!fu-berlin.de!uni-berlin.de!not-for-mail |
|---|---|
| From | MRAB <python@mrabarnett.plus.com> |
| Newsgroups | comp.lang.python |
| Subject | Re: Best (simplest) way to share data between processes |
| Date | Sun, 7 Jul 2024 23:47:01 +0100 |
| Lines | 20 |
| Message-ID | <mailman.15.1720392424.2981.python-list@python.org> (permalink) |
| References | <9a8nlk-jb81.ln1@q957.zbmc.eu> <B4D7CB24-28E5-4CAC-AA42-5C47C3F6F470@barrys-emacs.org> <6e86fff1-d24c-42c9-bc72-7e22757686ec@mrabarnett.plus.com> |
| Mime-Version | 1.0 |
| Content-Type | text/plain; charset=UTF-8; format=flowed |
| Content-Transfer-Encoding | 7bit |
| X-Trace | news.uni-berlin.de iaoOKKQhnD8j8Z4ST+GLWw8+wNT/TlrAIkQB45Skc05g== |
| Cancel-Lock | sha1:GQTrPy2svG1dF5ewfPsnZsK6sQU= sha256:2duPQ3HL4k1luvhCDffPMOJ240jhmNhuS85UDTS8OjQ= |
| Return-Path | <python@mrabarnett.plus.com> |
| X-Original-To | python-list@python.org |
| Delivered-To | python-list@mail.python.org |
| Authentication-Results | mail.python.org; dkim=pass reason="2048-bit key; unprotected key" header.d=plus.com header.i=@plus.com header.b=Ny/W/QCn; 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; 'from:addr:python': 0.09; 'linux': 0.09; 'received:192.168.1.64': 0.09; 'subject:between': 0.09; 'barry': 0.16; 'behaviour': 0.16; 'both.': 0.16; 'from:addr:mrabarnett.plus.com': 0.16; 'from:name:mrab': 0.16; 'instead.': 0.16; 'message- id:@mrabarnett.plus.com': 0.16; 'received:84.93': 0.16; 'received:84.93.230': 0.16; 'received:plus.net': 0.16; 'subject:way': 0.16; 'windows.': 0.16; 'wrote:': 0.16; 'values': 0.17; 'to:addr:python-list': 0.20; "i'd": 0.24; 'pattern': 0.26; 'old': 0.27; 'chris': 0.28; 'header:User-Agent:1': 0.30; 'python- list': 0.32; 'received:192.168.1': 0.32; 'but': 0.32; 'there': 0.33; 'windows': 0.34; 'same': 0.34; 'header:In-Reply-To:1': 0.34; 'close': 0.35; 'target': 0.36; 'received:192.168': 0.37; 'file': 0.38; 'use': 0.39; 'both': 0.40; 'skip:o 10': 0.61; 'lock': 0.64; 'guaranteed': 0.67; 'prevent': 0.67; 'clarity': 0.69; 'mix': 0.69; 'contents,': 0.84; 'simultaneous': 0.84; 'tmp': 0.84; 'green': 0.96 |
| DKIM-Signature | v=1; a=rsa-sha256; c=relaxed/relaxed; d=plus.com; s=042019; t=1720392422; bh=dF4UNapqHZpfXxobNLAUHzvla/rXqLtYRC3WxtMMoCo=; h=Date:Subject:To:References:From:In-Reply-To; b=Ny/W/QCn32QccgiGRGETghChymtQspuWRM325og0lKh7sL2Qw+1WE0UcloFFYmfJE 5lUDvT3+FjoS/umEQhRpeeQ9+e93uB2/WDdBVDPC5v1i4GDy2X1+gohVqlL/mnN03I MaUh6rqcc7iTBMO0H5rnk1UqPRHLWKUglTtHFHtgeCRK1eakpCaewKLCiiIkqj0V+t bCvXLN/jeE1ssQfEx9mJXU2SudQw1l9yS19ahJK0J9K2WNGKPvoJj4gfAuTeWNIGN7 H3GoVhevYaXDX+HshUTGgsBbKsmOGIImY4IG5m13e1xukf8chRcnX+d/ip6UAc87QX RPu/9TOEvvjLQ== |
| X-Clacks-Overhead | "GNU Terry Pratchett" |
| X-CM-Score | 0.00 |
| X-CNFS-Analysis | v=2.4 cv=AfoSHGXG c=1 sm=1 tr=0 ts=668b1ae6 a=0nF1XD0wxitMEM03M9B4ZQ==:117 a=0nF1XD0wxitMEM03M9B4ZQ==:17 a=IkcTkHD0fZMA:10 a=8AHkEIZyAAAA:8 a=D8jjOKPysQHQejHcGhQA:9 a=QEXdDO2ut3YA:10 a=zZCYzV9kfG8A:10 |
| X-AUTH | mrabarnett@:2500 |
| User-Agent | Mozilla Thunderbird |
| Content-Language | en-GB |
| In-Reply-To | <B4D7CB24-28E5-4CAC-AA42-5C47C3F6F470@barrys-emacs.org> |
| X-CMAE-Envelope | MS4xfKNAfY4Y2WI4dBK4ygthiUoZYrILj8qdtfXu3u5CuzDcHn2hEXPe288HpbTFV/DtTefKtw9XyXxe+LKhdFPsv89761vWPDBLRt/yQ5p7+6FDxZB9Y7F1 XMX95ofdQ3PHL/vT3W66al2bWd35uflAAKGR9fpetU2YOfktmTEn16BNaDMSYnvO1ANvq06/2Sl65ataDtWS8lgD8GHsbixnsac= |
| 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 | <6e86fff1-d24c-42c9-bc72-7e22757686ec@mrabarnett.plus.com> |
| X-Mailman-Original-References | <9a8nlk-jb81.ln1@q957.zbmc.eu> <B4D7CB24-28E5-4CAC-AA42-5C47C3F6F470@barrys-emacs.org> |
| Xref | csiph.com comp.lang.python:196400 |
Show key headers only | View raw
On 2024-07-07 23:27, Barry via Python-list wrote: > > >> On 7 Jul 2024, at 22:13, Chris Green via Python-list <python-list@python.org> wrote: >> >> 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 the old file contents or all the new file contents, never a mix of both. > For clarity I'd recommend os.replace instead. This is because on Windows os.rename it would complain if the target file already exists, but os.replace has the same behaviour on both Linux and Windows.
Back to comp.lang.python | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
Best (simplest) way to share data between processes Chris Green <cl@isbd.net> - 2024-07-06 08:28 +0100
Re: Best (simplest) way to share data between processes Gordinator <gordinator@gordinator.org> - 2024-07-06 20:03 +0100
Re: Best (simplest) way to share data between processes Piergiorgio Sartor <piergiorgio.sartor.this.should.not.be.used@nexgo.REMOVETHIS.de> - 2024-07-06 21:32 +0200
Re: Best (simplest) way to share data between processes Chris Green <cl@isbd.net> - 2024-07-08 13:52 +0100
Re: Best (simplest) way to share data (Posting On Python-List Prohibited) Lawrence D'Oliveiro <ldo@nz.invalid> - 2024-07-07 01:43 +0000
Re: Best (simplest) way to share data (Posting On Python-List Prohibited) Chris Green <cl@isbd.net> - 2024-07-08 13:56 +0100
Re: Best (simplest) way to share data (Posting On Python-List Prohibited) Lawrence D'Oliveiro <ldo@nz.invalid> - 2024-07-09 05:52 +0000
Re: Best (simplest) way to share data Chris Green <cl@isbd.net> - 2024-07-09 11:02 +0100
Re: Best (simplest) way to share data between processes Barry <barry@barrys-emacs.org> - 2024-07-07 23:27 +0100
Re: Best (simplest) way to share data between processes MRAB <python@mrabarnett.plus.com> - 2024-07-07 23:47 +0100
Re: Best (simplest) way to share data between processes Barry Scott <barry@barrys-emacs.org> - 2024-07-08 09:34 +0100
Re: Best (simplest) way to share data between processes Left Right <olegsivokon@gmail.com> - 2024-07-07 23:55 +0200
csiph-web