My solution was to implement my custom slave context, deriving it from ModbusSlaveContext. I implement a custom version of setValues, with an additional parameters dont_persist (which defaults to 0, meaning the value must be written to a file on disk). Then, in my updating function, I pass the value True to this argument, which means the value is not written to file.