Re: Best (simplest) way to share data between processes

2024-07-08 Thread Chris Green via Python-list
Piergiorgio Sartor wrote: > On 06/07/2024 09.28, Chris Green wrote: > > I have a Raspberry Pi in my boat that uses I2C to read a number of > > voltages and currents (using ADS1115 A2D) so I can monitor the battery > > condition etc. > > > > At present various different scripts (i.e. processes) j

Re: Best (simplest) way to share data between processes

2024-07-08 Thread Left Right via Python-list
If resource usage isn't an issue, then the _easy_ thing to do, that would also be easily correct is to have a server doing all the h/w-related reading and clients talking to that server. Use for the server the technology you feel most confident with. Eg. you may use Python's http package. I believe

Re: Best (simplest) way to share data between processes

2024-07-08 Thread Barry Scott via Python-list
> On 7 Jul 2024, at 23:47, MRAB via Python-list wrote: > > 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. Agreed. In this case the O

Re: Best (simplest) way to share data between processes

2024-07-07 Thread MRAB via Python-list
On 2024-07-07 23:27, Barry via Python-list wrote: On 7 Jul 2024, at 22:13, Chris Green via Python-list 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.

Re: Best (simplest) way to share data between processes

2024-07-07 Thread Barry via Python-list
> On 7 Jul 2024, at 22:13, Chris Green via Python-list > 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 th

Re: Best (simplest) way to share data between processes

2024-07-07 Thread Gordinator via Python-list
On 06/07/2024 12:32, Stefan Ram wrote: But why overengineer? If you feel comfortable with the file solution, go for it! The only drawback might be that it's a bit slower than other approaches. I absolutely agree. Overengineering is generally a bad idea because you're using a complex s

Re: Best (simplest) way to share data between processes

2024-07-07 Thread Piergiorgio Sartor via Python-list
On 06/07/2024 09.28, Chris Green wrote: I have a Raspberry Pi in my boat that uses I2C to read a number of voltages and currents (using ADS1115 A2D) so I can monitor the battery condition etc. At present various different scripts (i.e. processes) just read the values using the I2C bus whenever t

Best (simplest) way to share data between processes

2024-07-07 Thread Chris Green via Python-list
I have a Raspberry Pi in my boat that uses I2C to read a number of voltages and currents (using ADS1115 A2D) so I can monitor the battery condition etc. At present various different scripts (i.e. processes) just read the values using the I2C bus whenever they need to but I'm pretty sure this (quit