ACID Transactions at the File System
<p>Background:</p>

<p>I am getting a temperature float from an arduino via a serial connection. I need to be able to cache this temperature data every 30 seconds for other applications (e.g. web, thermostat controller) to access and not overload the serial connection.</p>

<p>Currently I cache this data to RAM as a file in /run (I'm trying to follow Linux convention). Then, other applications can poll the file for the temperature as they want it all day long with i/o now the only bottle neck (using an rpi, so not a lot of enterprise-level need here).</p>

<p>Problem:</p>

<p>I think when an app reads these files, it risks reading corrupt data. Should a writer update the file, and a reader try to read the file at the same time, can corrupt data be read, causing the thermostat to behave erratically? </p>

<p>Should I just use sqlite3 as an overkill solution, or use file locks (and does that risk something else not working perfectly)?</p>

<p>This is all taking place in multiple python processes. Is Linux able to handle this situation natively or do I need to apply somehow the principles mentioned <a href="https://blog.gocept.com/2013/07/15/reliable-file-updates-with-python/" rel="nofollow">here</a>? </p>