Lawrence D'Oliveiro <ldo@nz.invalid> wrote: > 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. > There's a separate (crontab driven) process that writes the history to a sqlite3 database,
> 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? That's exactly the sort of solution I was wondering about. Is there a ready made module/library for handling this sort of thing? Basically it will just be a string of a few tens of characters that would be kept up to date by one process and asked for by all the others. -- Chris Green · -- https://mail.python.org/mailman/listinfo/python-list