Sujet : Re: Best (simplest) way to share data (Posting On Python-List Prohibited)
De : ldo (at) *nospam* nz.invalid (Lawrence D'Oliveiro)
Groupes : comp.lang.pythonDate : 07. Jul 2024, 03:43:16
Autres entêtes
Organisation : A noiseless patient Spider
Message-ID : <v6crrk$1kfb$6@dont-email.me>
References : 1
User-Agent : Pan/0.158 (Avdiivka; )
On Sat, 6 Jul 2024 08:28:41 +0100, Chris Green wrote:
One fairly obvious way is to have single process/script which reads the
A2D values continuously and writes them to a file. All other scripts
then read from the file as needed, a simple file lock can then be used
to prevent simultaneous access (well, simultaneous access when the
writing process is writing).
The thing with a file is, it persists even when the collector process is
not running. Do you want data that persists when the collector process is
not running?
Is this a history of values, or just a snapshot of current values? A
history of values could be written to a database. Databases provide their
own transactions and interlocking to prevent readers from reading partial
updates.
If it’s a snapshot of current values, that does not persist when the
collector process is not running, then why not just keep the data in the
memory of the collector process, and have it concurrently listen on a
socket for connections from readers requesting a copy of the current data?